Multiple Progress Bars in StatusStrip

后端 未结 1 1775
逝去的感伤
逝去的感伤 2021-01-23 17:41

I have an application where there can be several lengthy (minutes) tasks happening simultaneously in the background (i.e. the same task for different accounts, some accounts tak

1条回答
  •  醉梦人生
    2021-01-23 18:29

    Probably it's not an intelligent UI design, but just for your information, you can add any control using ToolStripControlHost. Here is a simple example which lets you add multiple StatusBar controls in a single item of StatusStrip using code:

    ToolStripControlHost host;
    FlowLayoutPanel panel;
    private void button1_Click(object sender, EventArgs e)
    {
        if (panel == null)
        {
            panel = new FlowLayoutPanel();
            panel.FlowDirection = FlowDirection.TopDown;
            panel.WrapContents = false;
            panel.AutoSize = true;
            panel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
        }
        if (host == null)
        {
            host = new ToolStripControlHost(panel);
            this.statusStrip1.Items.Add(host);
        }
        panel.Controls.Add(new ProgressBar() { /* Value = new Random().Next(0, 100) */ });
    }
    

    Note: You also can extend ToolStripControlHost to provide design-time support, to do so take a look at How to: Wrap a Windows Forms Control with ToolStripControlHost.

    0 讨论(0)
提交回复
热议问题