StatusBarPanel StatusBarPanel StatusBarPanel StatusBarPanel Class

定義

代表 StatusBar 控制項中的面板。Represents a panel in a StatusBar control. 雖然 StatusStrip 控制項會在前幾個版本的 StatusBar 控制項中取代並新增功能,您還是可以選擇保留 StatusBar 以提供回溯相容性 (Backward Compatibility) 或供未來使用。Although the StatusStrip control replaces and adds functionality to the StatusBar control of previous versions, StatusBar is retained for both backward compatibility and future use if you choose.

public ref class StatusBarPanel : System::ComponentModel::Component, System::ComponentModel::ISupportInitialize
public class StatusBarPanel : System.ComponentModel.Component, System.ComponentModel.ISupportInitialize
type StatusBarPanel = class
    inherit Component
    interface ISupportInitialize
Public Class StatusBarPanel
Inherits Component
Implements ISupportInitialize
繼承
實作

範例

下列程式碼範例會在StatusBar表單上建立控制項, 並StatusBarPanel加入兩個物件。The following code example creates a StatusBar control on a form and adds two StatusBarPanel objects. 第一個StatusBarPanel(名panel1為) 會顯示應用程式的狀態文字。The first StatusBarPanel, named panel1, displays status text for an application. 第二StatusBarPanel個 ( panel2名為) 會顯示ToolTipText目前的日期, 並StatusBarPanel使用類別的屬性來顯示目前的時間。The second StatusBarPanel, named panel2, displays the current date and uses the ToolTipText property of the StatusBarPanel class to display the current time. 這個範例會使用ShowPanels屬性來確保顯示面板, 而不是標準面板, 並Panels使用屬性來StatusBar.StatusBarPanelCollection存取Add的方法, 將面板StatusBar加入至。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. 此範例也會使用AutoSizeBorderStyleToolTipTextText屬性來初始化StatusBarPanel物件。The example also uses the AutoSize, BorderStyle, ToolTipText, and Text properties to initialize the StatusBarPanel objects. 這個範例假設在範例中定義的方法, 並從的Form函式中呼叫。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 = 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

備註

StatusBarPanel代表控制項StatusBarStatusBar.StatusBarPanelCollection的個別面板。A StatusBarPanel represents an individual panel in the StatusBar.StatusBarPanelCollection of a StatusBar control. StatusBarPanel可以包含文字和 (或) 可用於反映應用程式狀態的圖示。A StatusBarPanel can contain text and/or an icon that can be used to reflect the status of an application. 使用 (可StatusBar透過控制項的StatusBar.Panels屬性存取) 來取出、加入或移除個人StatusBarPanelStatusBar.StatusBarPanelCollectionUse the StatusBar.StatusBarPanelCollection, accessible through the StatusBar.Panels property of a StatusBar control, to retrieve, add, or remove an individual StatusBarPanel.

提供的屬性可讓您修改StatusBar控制項內面板的顯示行為。 StatusBarPanelThe StatusBarPanel provides properties that enable you to modify the display behavior of a panel within a StatusBar control. 您可以使用Icon屬性, 在面板中顯示圖示。You can use the Icon property to display an icon within a panel. 這個屬性可以用來提供應用程式中狀態的圖形表示。This property can be used to provide a graphical representation of state in an application. Alignment屬性可讓您指定文字和/或圖示在面板中的對齊方式。The Alignment property enables you to specify how text and/or an icon is aligned within the panel. 若要確保您的面板已適當調整大小以符合面板的文字, 您可以使用AutoSize屬性, 自動調整面板的大小以符合面板的文字, 或填滿StatusBar控制項內的剩餘空間。To ensure that your panel is sized properly to fit the text of the panel, you can use the AutoSize property to automatically resize the panel to fit the text of the panel or to fill the remaining space within the StatusBar control. MinWidth屬性可讓您指定面板的最小寬度, 以確保它不會小於要顯示的資料。The MinWidth property enables you to specify a minimum width for the panel to ensure that it does not get smaller than the data it is intended to display.

StatusBar控制項通常用來顯示應用程式的說明資訊或狀態資訊。The StatusBar control is typically used to display Help information or state information about your application. 通常, 請務必顯示面板中所呈現之資料的其他資訊。Often, it is important to display additional information about data that is presented in a panel. 每當滑鼠指標停留ToolTipText在面板上時, 您就可以使用屬性來顯示資訊。You can use the ToolTipText property to display information whenever the mouse pointer rests on a panel.

雖然此StatusBar控制項通常用來顯示文字資訊, 但您也可以將自己的顯示類型提供StatusBarPanel給。Although the StatusBar control is typically used to display textual information, you can also provide your own type of display to a StatusBarPanel. 屬性可讓您指定StatusBarPanel將如何繪製。 StyleThe Style property enables you to specify how the StatusBarPanel will be drawn. 根據預設, Style屬性會用來顯示Text屬性的值 (如果在Icon屬性中指定, 則會使用圖示)。By default, the Style property is used to display the value of the Text property (and an icon, if specified in the Icon property). 如果屬性設定為OwnerDraw, 您可以在面板中繪製您自己的資訊。If the property is set to OwnerDraw, you can draw your own information into the panel. 您可以使用這項功能, 在面板中繪製進度列或動畫圖標。You can use this feature to draw a progress bar or an animated icon in the panel.

當您建立StatusBarPanel類別的實例時, 讀取/寫入屬性會設定為初始值。When you create an instance of the StatusBarPanel class, the read/write properties are set to initial values. 如需這些值的清單, 請參閱StatusBarPanel函數。For a list of these values, see the StatusBarPanel constructor.

建構函式

StatusBarPanel() StatusBarPanel() StatusBarPanel() StatusBarPanel()

初始化 StatusBarPanel 類別的新執行個體。Initializes a new instance of the StatusBarPanel class.

屬性

Alignment Alignment Alignment Alignment

取得或設定狀態列面板內文字與圖示的對齊方式。Gets or sets the alignment of text and icons within the status bar panel.

AutoSize AutoSize AutoSize AutoSize

取得或設定值,指出狀態列面板是否會自動調整大小。Gets or sets a value indicating whether the status bar panel is automatically resized.

BorderStyle BorderStyle BorderStyle BorderStyle

取得或設定狀態列面板的框線樣式。Gets or sets the border style of the status bar panel.

CanRaiseEvents CanRaiseEvents CanRaiseEvents CanRaiseEvents

取得值,指出元件是否能引發事件。Gets a value indicating whether the component can raise an event.

(Inherited from Component)
Container Container Container Container

取得包含 IContainerComponentGets the IContainer that contains the Component.

(Inherited from Component)
DesignMode DesignMode DesignMode DesignMode

取得值,指出 Component 目前是否處於設計模式。Gets a value that indicates whether the Component is currently in design mode.

(Inherited from Component)
Events Events Events Events

取得附加在這個 Component 上的事件處理常式清單。Gets the list of event handlers that are attached to this Component.

(Inherited from Component)
Icon Icon Icon Icon

取得或設定要在狀態列面板內顯示的圖示。Gets or sets the icon to display within the status bar panel.

MinWidth MinWidth MinWidth MinWidth

取得或設定 StatusBar 控制項內允許的狀態列面板最小寬度。Gets or sets the minimum allowed width of the status bar panel within the StatusBar control.

Name Name Name Name

取得或設定要套用至 StatusBarPanel 的名稱。Gets or sets the name to apply to the StatusBarPanel.

Parent Parent Parent Parent

取得裝載狀態列面板的 StatusBar 控制項。Gets the StatusBar control that hosts the status bar panel.

Site Site Site Site

取得或設定 ComponentISiteGets or sets the ISite of the Component.

(Inherited from Component)
Style Style Style Style

取得或設定狀態列面板的樣式。Gets or sets the style of the status bar panel.

Tag Tag Tag Tag

取得或設定包含 StatusBarPanel 相關資料的物件。Gets or sets an object that contains data about the StatusBarPanel.

Text Text Text Text

取得或設定狀態列面板的文字。Gets or sets the text of the status bar panel.

ToolTipText ToolTipText ToolTipText ToolTipText

取得或設定與狀態列面板相關的工具提示文字。Gets or sets ToolTip text associated with the status bar panel.

Width Width Width Width

取得或設定 StatusBar 控制項內、狀態列面板的寬度。Gets or sets the width of the status bar panel within the StatusBar control.

方法

BeginInit() BeginInit() BeginInit() BeginInit()

開始初始化 StatusBarPanelBegins the initialization of a StatusBarPanel.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose() Dispose() Dispose() Dispose()

釋放 Component 所使用的所有資源。Releases all resources used by the Component.

(Inherited from Component)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

釋放 StatusBarPanel 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by the StatusBarPanel and optionally releases the managed resources.

EndInit() EndInit() EndInit() EndInit()

結束初始化 StatusBarPanelEnds the initialization of a StatusBarPanel.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetService(Type) GetService(Type) GetService(Type) GetService(Type)

傳回表示 Component 或其 Container 所提供之服務的物件。Returns an object that represents a service provided by the Component or by its Container.

(Inherited from Component)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

取得存留期服務物件,以控制這個執行個體的存留期原則。Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
ToString() ToString() ToString() ToString()

擷取字串,其中包含面板的相關資訊。Retrieves a string that contains information about the panel.

事件

Disposed Disposed Disposed Disposed

當此元件由 Dispose() 方法的呼叫處置時發生。Occurs when the component is disposed by a call to the Dispose() method.

(Inherited from Component)

適用於

另請參閱