C# 在C中使用StatusStrip#
考虑一下。我已经在我的Windows窗体应用程序中添加了一个StatusStrip,但是我遇到了一些问题 我希望在StatusStrip中有一个锚定在左侧的标签和一个锚定在右侧的progressbar,但我找不到设置这些属性的方法C# 在C中使用StatusStrip#,c#,winforms,anchor,statusstrip,C#,Winforms,Anchor,Statusstrip,考虑一下。我已经在我的Windows窗体应用程序中添加了一个StatusStrip,但是我遇到了一些问题 我希望在StatusStrip中有一个锚定在左侧的标签和一个锚定在右侧的progressbar,但我找不到设置这些属性的方法 然后我想我可能需要创建两个StatusStrip并将它们锚定在表单底部的任一侧。。。那没有成功;除此之外,它感觉不太好。您是否尝试将ProgresBarToolStripItem的属性设置为?只需将label控件上的Spring属性设置为True,您就可以开始了。您需
然后我想我可能需要创建两个StatusStrip并将它们锚定在表单底部的任一侧。。。那没有成功;除此之外,它感觉不太好。您是否尝试将ProgresBarToolStripItem的属性设置为?只需将label控件上的
Spring
属性设置为True
,您就可以开始了。您需要做的是将progressbar的对齐属性设置为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;
这可以通过statusStrip的默认表布局实现,只需在当前标签和progressBar之间放置另一个标签,并将Spring属性设置为true。打开设计器并设置
this.toolStripStatusLabel1.Alignment=System.Windows.Forms.ToolStripItemAlignment.Right 如果你这样做了,你还需要将标签的默认对齐方式从中心更改为左心。多亏了你们两位……太棒了!求你了,上帝-一定有办法在视觉上设置它。:)有。我正在展示设计器代码。只需在属性面板中查找属性…实际上,
对齐
属性在ToolStripStatusLabel
类的属性网格中不可用(出于某种原因,它具有可浏览(false)
属性,至少在.NET 4中是这样).谢谢-如果您想要多个右对齐标签,这是正确答案。不知道为什么这会被记下来。