首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在C#中使用StatusStrip

在C#中使用StatusStrip
EN

Stack Overflow用户
提问于 2009-01-14 18:01:10
回答 5查看 14.1K关注 0票数 13

System.Windows.Forms.StatusStrip为例。我已经向Windows Forms应用程序添加了一个StatusStrip,但我遇到了一些问题。

我希望在StatusStrip中有一个固定在左边的标签和一个固定在右边的进度条,但是我找不到一种方法来设置这些属性。

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

EN

回答 5

Stack Overflow用户

回答已采纳

发布于 2009-01-14 18:19:32

只需将label控件上的Spring属性设置为True,就可以了。

票数 29
EN

Stack Overflow用户

发布于 2009-01-14 18:21:40

你需要做的就是将进度条的对齐属性设置为right。然后将StatusStrip的LayoutStyle设置为HorizontalStackWithOverflow。

代码语言:javascript
复制
    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;
票数 7
EN

Stack Overflow用户

发布于 2009-01-14 18:23:46

这可以通过statusStrip的默认表格布局来实现,只需在当前标签和progressBar之间放置另一个标签,并将Spring属性设置为true。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/444031

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档