Export (0) Print
Expand All

How to: Set the Size of Status-Bar Panels

NoteNote

The ToolStripStatusLabel control replaces and adds functionality to the StatusBar control; however, the StatusBar control is retained for both backward compatibility and future use, if you choose.

Each instance of the StatusBarPanel class within a StatusBar Control (Windows Forms) control has a number of dynamic properties that determine its width and resize behavior at run time.

To set the size of a panel

  • In a procedure, set the AutoSize, MinWidth, and Width properties (or any subset therein) for the status-bar panels using their index passed through the Panels property of the StatusBarPanel collection.

    Public Sub SetStatusBarPanelSize()
    ' Create panel and set text property.
       StatusBar1.Panels.Add("One")
    ' Set properties of panels.
       StatusBar1.Panels(0).AutoSize = StatusBarPanelAutoSize.Spring
       StatusBar1.Panels(0).Width = 200
    ' Enable the StatusBar control to display panels.
       StatusBar1.ShowPanels = True
        End Sub
    
    

    public void SetStatusBarPanelSize()
    {
       // Create panel and set text property.
       statusBar1.Panels.Add("One");
       // Set properties of panels.
       statusBar1.Panels[0].AutoSize = StatusBarPanelAutoSize.Spring;
       statusBar1.Panels[0].Width = 200;
       statusBar1.ShowPanels = true;
    }
    
    

    public:
       void SetStatusBarPanelSize()
       {
          // Create panel and set text property.
          statusBar1->Panels->Add("One");
          // Set properties of panels.
          statusBar1->Panels[0]->AutoSize =
             StatusBarPanelAutoSize::Spring;
          statusBar1->Panels[0]->Width = 200;
          statusBar1->ShowPanels = true;
       }
    

See Also

Community Additions

ADD
Show:
© 2014 Microsoft