Export (0) Print
Expand All

Setting the Size of Status-Bar Panels

Visual Studio .NET 2003

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

To set the size of a panel at design time

  1. In the Properties window, click the Panel property to select it. Then click the Ellipsis ( Aa984422.vbellipsesbutton(en-us,VS.71).gif ) button to open the StatusBarPanel Collection Editor.
  2. Set some or all of the following properties in the property window that appears in the pane on the right side of the StatusBarPanel Collection Editor:
    PropertyDescription
    AutoSizeDetermines the resize behavior of the panel. Must be one of the values of the StatusBarPanelAutoSize enumeration.
    WidthSets the width in pixels of the panel. Can change when form is resized depending on the setting of the AutoSize property.
    MinWidthThe minimum width the panel can be within the status bar.

To set the size of a panel programmatically

  • In a procedure, set the AutoSize, MinWidth, and Width properties (or any subset therein) for the status-bar panels using their index passed via the Panels property of the StatusBarPanels collection.
    ' Visual Basic
    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
    
    // C#
    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;
    }
    
    // C++
    public:
       void SetStatusBarPanelSize()
       {
          // Create panel and set text property.
          statusBar1->Panels->Add("One");
          // Set properties of panels.
          statusBar1->Panels->Item[0]->AutoSize =
             StatusBarPanelAutoSize::Spring;
          statusBar1->Panels->Item[0]->Width = 200;
          statusBar1->ShowPanels = true;
       }
    

See Also

Walkthrough: Updating Status-Bar Information at Run Time | Determining Which Panel in the Windows Forms StatusBar Control Was Clicked | Introduction to the Windows Forms StatusBar Control | StatusBar Class

Show:
© 2015 Microsoft