Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

StatusBarPanel.BorderStyle Property

Gets or sets the border style of the status bar panel.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
public StatusBarPanelBorderStyle BorderStyle { get; set; }

Property Value

Type: System.Windows.Forms.StatusBarPanelBorderStyle
One of the StatusBarPanelBorderStyle values. The default is Sunken.
ExceptionCondition
InvalidEnumArgumentException

The value assigned to the property is not a member of the StatusBarPanelBorderStyle enumeration.

You can use this property to differentiate a panel from other panels in a StatusBar control.

The following code example creates a StatusBar control on a form and adds two StatusBarPanel objects. The first StatusBarPanel, named panel1, displays status text for an application. The second StatusBarPanel, named panel2, displays the current date and uses the ToolTipText property of the StatusBarPanel class to display the current time. The example uses the ShowPanels property to ensure that the panels are displayed instead of a standard panel, and it uses the Panels property to access the Add method of the StatusBar.StatusBarPanelCollection to add the panels to the StatusBar. The example also uses the AutoSize, BorderStyle, ToolTipText, and Text properties to initialize the StatusBarPanel objects. This example assumes that the method defined in the example is defined and called from the constructor of a Form.

		private void 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);
		}

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.