以System.Windows.Forms.StatusStrip为例。我已经向Windows Forms应用程序添加了一个StatusStrip,但我遇到了一些问题。
我希望在StatusStrip中有一个固定在左边的标签和一个固定在右边的进度条,但是我找不到一种方法来设置这些属性。
然后我想,我可能需要创建两个StatusStrips,并将它们锚定在表单底部的任意一侧……这并没有成功;除此之外,感觉就是不对劲。
发布于 2009-01-14 18:19:32
只需将label控件上的Spring属性设置为True,就可以了。
发布于 2009-01-14 18:21:40
你需要做的就是将进度条的对齐属性设置为right。然后将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;发布于 2009-01-14 18:23:46
这可以通过statusStrip的默认表格布局来实现,只需在当前标签和progressBar之间放置另一个标签,并将Spring属性设置为true。
https://stackoverflow.com/questions/444031
复制相似问题