Live Chat Icon For mobile
Live Chat Icon

How do I put controls such as a ProgressBar into a StatusBar ?

Platform: WPF| Category: StatusBar

You cannot place controls into a StatusBar control in the Designer. However, you can add any number of controls to the StatusBar programmatically through it’s ‘Controls’ property. After adding the controls, set their Visible, Location, Bounds and other properties.

Here’s a sample method that could be called in a form’s constructor after the ’InitializeComponent’.

[C#]

 private void AddStatusBarControls(StatusBar sb)
        {
            ProgressBar pb = new ProgressBar();
            sb.Controls.Add(pb);

            pb.Visible = true;
            pb.Bounds = new Rectangle(sb.Width / 4, 4, sb.Width / 2, sb.Height - 8);
            pb.Anchor = AnchorStyles.Left | AnchorStyles.Right;
        }

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.