考虑System.Windows.Forms.StatusStrip。我已在我的 Windows 窗体应用程序中添加了一个 StatusStrip,但我遇到了一些问题。
我想在 StatusStrip 的左侧锚定一个标签,并在右侧锚定一个进度条,但我找不到设置这些属性的方法。
然后我想我可能需要创建两个 StatusStrips 并将它们锚定在表单底部的任一侧......这并没有成功;除此之外,它只是感觉不对。
考虑System.Windows.Forms.StatusStrip。我已在我的 Windows 窗体应用程序中添加了一个 StatusStrip,但我遇到了一些问题。
我想在 StatusStrip 的左侧锚定一个标签,并在右侧锚定一个进度条,但我找不到设置这些属性的方法。
然后我想我可能需要创建两个 StatusStrips 并将它们锚定在表单底部的任一侧......这并没有成功;除此之外,它只是感觉不对。
只需将Spring
标签控件上的属性设置为就True
可以了。
您需要做的是将进度条的对齐属性设置为正确。然后将 StatusStrip 的 LayoutStyle 设置为 HorizontalStackWithOverflow。
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;
这可以通过 statusStrip 的默认表格布局来实现,只需在当前标签和 progressBar 之间放置另一个标签并将 Spring 属性设置为 true。
打开您的设计器并设置 this.toolStripStatusLabel1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;