在C#中使用StatusStrip

Bra*_*rad 13 c# anchor statusstrip winforms

考虑System.Windows.Forms.StatusStrip.我已经将StatusStrip添加到我的Windows窗体应用程序中,但是我遇到了一些问题.

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

然后我想我可能需要创建两个StatusStrips并将它们锚定在表单底部的任何一侧...这没有成功; 除此之外,它感觉不对劲.

Sea*_*ght 29

只需Spring在标签控件上设置属性即可True,您应该很高兴.

  • 如果这样做,您还需要将标签的默认对齐方式从MiddleCenter更改为LeftCenter. (7认同)

Ste*_*nke 7

您需要做的是将进度条的对齐属性设置为右侧.然后将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;
Run Code Online (Sandbox Code Playgroud)