StatusBar.StatusBarPanelCollection 類別

定義

代表 StatusBar 控制項內的面板集合。

public: ref class StatusBar::StatusBarPanelCollection : System::Collections::IList
public class StatusBar.StatusBarPanelCollection : System.Collections.IList
[System.ComponentModel.ListBindable(false)]
public class StatusBar.StatusBarPanelCollection : System.Collections.IList
type StatusBar.StatusBarPanelCollection = class
    interface IList
    interface ICollection
    interface IEnumerable
[<System.ComponentModel.ListBindable(false)>]
type StatusBar.StatusBarPanelCollection = class
    interface IList
    interface ICollection
    interface IEnumerable
Public Class StatusBar.StatusBarPanelCollection
Implements IList
繼承
StatusBar.StatusBarPanelCollection
屬性
實作

範例

下列程式碼範例會在表單上建立 控制項,並新增兩 StatusBarPanelStatusBar 物件。 其中 StatusBarPanel 一個名為 panel1 的 ,會顯示應用程式的狀態文字。 第二 StatusBarPanel 個名為 panel2 的 會顯示目前的日期,並使用 ToolTipText 類別的 StatusBarPanel 屬性來顯示目前的時間。 此範例會 ShowPanels 使用 屬性來確保顯示面板,而不是標準面板,而且會使用 和 Panels 屬性來存取 Add 的 方法 StatusBar.StatusBarPanelCollection ,以將面板新增至 StatusBar 。 此範例也會使用 AutoSizeBorderStyle ToolTipTextText 屬性來初始化 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.StatusBarPanelCollection 會儲存顯示在 中的 StatusBar 面板。 集合中的每個物件都是 類別的實例, StatusBarPanel 可定義 中所 StatusBar 顯示面板的顯示特性和行為。

有數種方式可將面板新增至集合。 方法 Add 可讓您將單一面板新增至集合。 若要將一些面板新增至集合,您可以建立 物件的陣列 StatusBarPanel ,並將它指派給 AddRange 方法。 如果您想要在集合內的特定位置插入面板,您可以使用 Insert 方法。 若要移除面板,如果您知道面板位於集合中的位置,則可以使用 Remove 方法或 RemoveAt 方法。 方法 Clear 可讓您從集合中移除所有面板,而不是使用 Remove 方法一次移除單一面板。

除了新增和移除面板的方法和屬性之外, StatusBar.StatusBarPanelCollection 也會提供方法來尋找集合中的面板。 方法 Contains 可讓您判斷面板是否為集合的成員。 一旦您知道面板位於集合中,您就可以使用 IndexOf 方法來判斷面板在集合中的位置。

建構函式

StatusBar.StatusBarPanelCollection(StatusBar)

初始化 StatusBar.StatusBarPanelCollection 類別的新執行個體。

屬性

Count

取得集合中的項目數目。

IsReadOnly

取得表示這個集合是否為唯讀的值。

Item[Int32]

取得或設定在指定索引處的 StatusBarPanel

Item[String]

從集合中取得具有指定索引鍵的項目。

方法

Add(StatusBarPanel)

StatusBarPanel 加入集合。

Add(String)

將含有指定文字的 StatusBarPanel 加入集合中。

AddRange(StatusBarPanel[])

StatusBarPanel 物件陣列加入集合。

Clear()

移除集合的所有項目。

Contains(StatusBarPanel)

判斷指定的面板是否位於集合中。

ContainsKey(String)

判斷集合是否包含具有指定索引鍵的 StatusBarPanel

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetEnumerator()

傳回列舉程式,其可用來在項目集合中重複。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
IndexOf(StatusBarPanel)

傳回指定面板集合中的索引。

IndexOfKey(String)

傳回具有指定索引鍵之 StatusBarPanel 第一次出現的索引。

Insert(Int32, StatusBarPanel)

將指定的 StatusBarPanel 插入至集合中的指定索引處。

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
Remove(StatusBarPanel)

從集合移除指定的 StatusBarPanel

RemoveAt(Int32)

移除位在集合內指定索引上的 StatusBarPanel

RemoveByKey(String)

從集合中移除具有指定索引鍵的 StatusBarPanel

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

ICollection.CopyTo(Array, Int32)

從目標陣列的指定索引開始,將 StatusBar.StatusBarPanelCollection 複製到相容的一維陣列中。

ICollection.IsSynchronized

取得值,表示是否同步化存取集合 (執行緒安全)。

ICollection.SyncRoot

取得物件,這個物件可以用來對集合進行同步存取。

IList.Add(Object)

此 API 支援此產品基礎結構,但無法直接用於程式碼之中。

StatusBarPanel 加入集合。

IList.Contains(Object)

判斷指定的面板是否位於集合中。

IList.IndexOf(Object)

傳回集合中指定之面板的索引。

IList.Insert(Int32, Object)

將指定的 StatusBarPanel 插入至集合中的指定索引處。

IList.IsFixedSize

取得值,這個值表示集合的大小是否是固定的。

IList.Item[Int32]

在指定的索引位置上取得或設定項目。

IList.Remove(Object)

從集合移除指定的 StatusBarPanel

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。

AsParallel(IEnumerable)

啟用查詢的平行化作業。

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryable

適用於

另請參閱