StatusBarPanel.BorderStyle 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定狀態列面板的框線樣式。
public:
property System::Windows::Forms::StatusBarPanelBorderStyle BorderStyle { System::Windows::Forms::StatusBarPanelBorderStyle get(); void set(System::Windows::Forms::StatusBarPanelBorderStyle value); };
public System.Windows.Forms.StatusBarPanelBorderStyle BorderStyle { get; set; }
member this.BorderStyle : System.Windows.Forms.StatusBarPanelBorderStyle with get, set
Public Property BorderStyle As StatusBarPanelBorderStyle
屬性值
其中一個 StatusBarPanelBorderStyle 值。 預設為 Sunken。
例外狀況
指派給屬性的值不是 StatusBarPanelBorderStyle 列舉的成員。
範例
下列程式碼範例會在表單上建立控制項,並新增兩 StatusBarPanel 個 StatusBar 物件。 名為 的第一個 StatusBarPanel 會顯示 panel1
應用程式的狀態文字。 名為 的第二 StatusBarPanel 個 panel2
,會顯示目前的日期,並使用 ToolTipText 類別的 StatusBarPanel 屬性來顯示目前時間。 此範例會 ShowPanels 使用 屬性來確保面板會顯示,而不是標準面板,並使用 Panels 屬性來存取 Add 的 方法 StatusBar.StatusBarPanelCollection ,將面板新增至 StatusBar 。 此範例也會使用 AutoSize 、 BorderStyle ToolTipText 和 Text 屬性來初始化 StatusBarPanel 物件。 這個範例假設範例中定義的方法是由 的建構函式所定義,並從 的 Form 建構函式呼叫。
private:
void CreateMyStatusBar()
{
// Create a StatusBar control.
StatusBar^ statusBar1 = gcnew StatusBar;
// Create two StatusBarPanel objects to display in the StatusBar.
StatusBarPanel^ panel1 = gcnew StatusBarPanel;
StatusBarPanel^ panel2 = gcnew 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 the time the application
// was started.
panel2->ToolTipText = System::DateTime::Now.ToShortTimeString();
// Set the text of the panel to the current date.
panel2->Text = "Started: " + 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 );
}
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);
}
Private Sub CreateMyStatusBar()
' Create a StatusBar control.
Dim statusBar1 As New StatusBar()
' Create two StatusBarPanel objects to display in the StatusBar.
Dim panel1 As New StatusBarPanel()
Dim panel2 As 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 the 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.
Me.Controls.Add(statusBar1)
End Sub
備註
您可以使用這個屬性來區分面板與控制項中的其他 StatusBar 面板。