2009-01-14 27 views
11

考虑System.Windows.Forms.StatusStrip。我添加了一个StatusStrip到我的Windows窗体应用程序,但是我遇到了一些问题。在C中使用状态栏#

我想在左边有一个标签,在StatusStrip的右边有一个进度条,但是我找不到设置这些属性的方法。

然后,我认为我可能需要创建两个StatusStrips并将它们锚定在窗体底部的任一侧......没有平移;除此之外,它只是感觉不对。

回答

27

只需将标签控件上的Spring属性设置为True,那么您应该很好。

+7

如果你这样做,你还想更改标签的默认对齐从MiddleCenter到LeftCenter。 – 2009-01-14 18:23:10

+0

感谢你们两个......完美! – Brad 2009-01-14 18:39:34

0

您是否尝试过将ProgresBarToolStripItem的Alignment属性设置为Right

+0

对齐不会与默认表格布局单独工作。 – 2009-01-14 18:29:21

+0

是的,我做了没有工作 – Brad 2009-01-14 18:34:47

7

你需要做的是将你的进度条的alignment属性设置为正确。然后将StatusStrip的LayoutStyle设置为Horizo​​ntalStackWithOverflow。

private void InitializeComponent() 
    { 
     this.statusStrip1 = new System.Windows.Forms.StatusStrip(); 
     this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); 
     this.toolStripProgressBar1 = new System.Windows.Forms.ToolStripProgressBar(); 
     this.statusStrip1.SuspendLayout(); 
     this.SuspendLayout(); 
     // 
     // statusStrip1 
     // 
     this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 
    this.toolStripStatusLabel1, 
    this.toolStripProgressBar1}); 
     this.statusStrip1.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.HorizontalStackWithOverflow; 
     this.statusStrip1.Location = new System.Drawing.Point(0, 250); 
     this.statusStrip1.Name = "statusStrip1"; 
     this.statusStrip1.Size = new System.Drawing.Size(467, 22); 
     this.statusStrip1.TabIndex = 0; 
     this.statusStrip1.Text = "statusStrip1"; 
     // 
     // toolStripStatusLabel1 
     // 
     this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; 
     this.toolStripStatusLabel1.Size = new System.Drawing.Size(117, 17); 
     this.toolStripStatusLabel1.Text = "toolStripStatusLabel1"; 
     // 
     // toolStripProgressBar1 
     // 
     this.toolStripProgressBar1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; 
     this.toolStripProgressBar1.Name = "toolStripProgressBar1"; 
     this.toolStripProgressBar1.Size = new System.Drawing.Size(100, 16); 

    } 

    private System.Windows.Forms.StatusStrip statusStrip1; 
    private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; 
    private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar1; 
2

这可以通过对StatusStrip中的默认表布局,只需将您的当前标签,你的进度,并设置弹簧属性为true之间的另一个标签来实现。

0

打开您的设计器并设置 this.toolStripStatusLabel1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;