StatusBarPanel.BorderStyle 属性

定义

获取或设置状态栏面板的边框样式。

C#
public System.Windows.Forms.StatusBarPanelBorderStyle BorderStyle { get; set; }

属性值

StatusBarPanelBorderStyle 值之一。 默认值为 Sunken

例外

分配给属性的值不是 StatusBarPanelBorderStyle 枚举的成员。

示例

下面的代码示例在窗体上创建一个 StatusBar 控件,并添加两 StatusBarPanel 个 对象。 第一个名为 StatusBarPanelpanel1显示应用程序的状态文本。 第二 StatusBarPanel个 (名为 panel2)显示当前日期,并使用 ToolTipText 类的 StatusBarPanel 属性来显示当前时间。 该示例使用 ShowPanels 属性来确保显示面板而不是标准面板,并使用 Panels 属性访问 AddStatusBar.StatusBarPanelCollection 方法,将面板添加到 StatusBar。 该示例还使用 AutoSizeBorderStyleToolTipTextText 属性来初始化 StatusBarPanel 对象。 此示例假定在 示例中定义的 方法已定义,并从 的 Form构造函数调用。

C#
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);
}

注解

可以使用此属性将面板与控件中的其他 StatusBar 面板区分开来。

适用于

产品 版本
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 10

另请参阅