为StatusStrip 添加分割线

想要在页面底部添加StatusStrip, 里面包含一个显示状态的label 和一个显示进度的progressbar。为了看着好看一点儿,想把他们分割开来,google了半天也没找到合适的办法,默认在页面上可以添加四种StatusStrip的控件。但都不能实现想要的分割开的效果:

最后想了个办法,把label的宽度设置成固定,然后加一个ToolStripSeparator,然后设置ToolStripSeparator的left margin,譬如20,就实现了分割的效果。

代码如下:

View Code
 1  // 
 2             // toolStripStatusLabel1
 3             // 
 4             this.toolStripStatusLabel1.AutoSize = false;
 5             this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
 6             this.toolStripStatusLabel1.Size = new System.Drawing.Size(250, 18);
 7             this.toolStripStatusLabel1.Text = "Idle";
 8             this.toolStripStatusLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
 9             // 
10             // toolStripSeparator1
11             // 
12             this.toolStripSeparator1.Margin = new System.Windows.Forms.Padding(30, 0, 0, 0);
13             this.toolStripSeparator1.Name = "toolStripSeparator1";
14             this.toolStripSeparator1.Size = new System.Drawing.Size(6, 23);
15             // 
16             // toolStripProgressBar1
17             // 
18             this.toolStripProgressBar1.Name = "toolStripProgressBar1";
19             this.toolStripProgressBar1.Size = new System.Drawing.Size(120, 17);
20             // 

大功告成,效果图如下

 

 

posted on 2012-11-01 17:28  林南  阅读(2353)  评论(0编辑  收藏  举报

导航