StatusBar Class

Represents a Windows status bar control. Although ToolStripStatusLabel replaces and adds functionality to the StatusBar control of previous versions, StatusBar is retained for both backward compatibility and future use if you choose.

Gets or sets a value indicating whether this control should redraw its surface using a secondary buffer to reduce or prevent flicker, however this property has no effect on the StatusBar control (Overrides Control.DoubleBuffered.)

Gets a value indicating whether the caller must call an invoke method when making method calls to the control because the caller is on a different thread than the one the control was created on. (Inherited from Control.)

Invalidates the specified region of the control (adds it to the control's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control. (Inherited from Control.)

Invalidates the specified region of the control (adds it to the control's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control. (Inherited from Control.)

Invalidates the specified region of the control (adds it to the control's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control. Optionally, invalidates the child controls assigned to the control. (Inherited from Control.)

Invalidates the specified region of the control (adds it to the control's update region, which is the area that will be repainted at the next paint operation), and causes a paint message to be sent to the control. Optionally, invalidates the child controls assigned to the control. (Inherited from Control.)

Typically, a StatusBar control consists of StatusBarPanel objects, each of which displays text and/or an icon. You can also provide owner-drawn panels to provide custom panels such as a progress bar or a series of images that displays the state of your application. A StatusBar control typically displays information about an object being viewed on a Form, the object's components, or contextual information that relates to that object's operation within your application.

The StatusBar control provides properties that enable you to customize the appearance of the control. If the StatusBar is displayed on a form that can be resized, you can use the SizingGrip property to display a sizing grip in the lower-right corner of the form to indicate to users that the form can be resized. The ShowPanels property enables you to display panels within your StatusBar or to display only the value of the Text property of the control.

If you want to determine when a StatusBarPanel object within a StatusBar control is clicked, you can create an event handler for the PanelClick event. To perform owner-draw operations on a panel, you can create an event handler for the DrawItem event. The event data passed to the event handler provides information on the panel to draw and a Graphics object to use to perform drawing tasks.

When you create an instance of StatusBar, the read/write properties are set to initial values. For a list of these values, see the StatusBar constructor.

privatevoid CreateMyStatusBar()
{
// Create a StatusBar control.
StatusBar statusBar1 = new StatusBar();
// Create two StatusBarPanel objects to display in the StatusBar.
StatusBarPanel panel1 = new StatusBarPanel();
StatusBarPanel panel2 = new StatusBarPanel();
// Display the first panel with a sunken border style.
panel1.BorderStyle = StatusBarPanelBorderStyle.Sunken;
// Initialize the text of the panel.
panel1.Text = "Ready...";
// Set the AutoSize property to use all remaining space on the StatusBar.
panel1.AutoSize = StatusBarPanelAutoSize.Spring;
// Display the second panel with a raised border style.
panel2.BorderStyle = StatusBarPanelBorderStyle.Raised;
// Create ToolTip text that displays time the application was //started.
panel2.ToolTipText = "Started: " + System.DateTime.Now.ToShortTimeString();
// Set the text of the panel to the current date.
panel2.Text = System.DateTime.Today.ToLongDateString();
// Set the AutoSize property to size the panel to the size of the contents.
panel2.AutoSize = StatusBarPanelAutoSize.Contents;
// Display panels in the StatusBar control.
statusBar1.ShowPanels = true;
// Add both panels to the StatusBarPanelCollection of the StatusBar.
statusBar1.Panels.Add(panel1);
statusBar1.Panels.Add(panel2);
// Add the StatusBar to the form. this.Controls.Add(statusBar1);
}