StatusBar.StatusBarPanelCollection 類別

定義

代表 StatusBar 控制項內的面板集合。Represents the collection of panels in a StatusBar control.

public: ref 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
Public Class StatusBar.StatusBarPanelCollection
Implements IList
繼承
StatusBar.StatusBarPanelCollection
屬性
實作

範例

下列程式碼範例會在StatusBar表單上建立控制項, 並StatusBarPanel加入兩個物件。The following code example creates a StatusBar control on a form and adds two StatusBarPanel objects. 名為StatusBarPanel panel1的其中一個會顯示應用程式的狀態文字。One of the 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 and 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

備註

類別會儲存顯示StatusBar在中的面板。 StatusBar.StatusBarPanelCollectionThe StatusBar.StatusBarPanelCollection class stores the panels displayed in the StatusBar. 集合中的每個物件都是StatusBarPanel類別的實例, 它會定義顯示StatusBar在中之面板的顯示特性和行為。Each object in the collection is an instance of the StatusBarPanel class which defines the display characteristics and behaviors of a panel displayed in a StatusBar.

有數種方式可以將面板新增至集合。There are a number of ways to add panels to the collection. Add方法提供將單一面板新增至集合的功能。The Add method provides the ability to add a single panel to the collection. 若要將多個面板加入集合中, 您可以建立物件的StatusBarPanel陣列, 並將它指派AddRange給方法。To add a number of panels to the collection, you create an array of StatusBarPanel objects and assign it to the AddRange method. 如果您想要在集合內的特定位置插入面板, 可以使用Insert方法。If you want to insert a panel at a specific location within the collection, you can use the Insert method. 若要移除面板, 您可以使用Remove方法RemoveAt或方法 (如果您知道面板位於集合內的位置)。To remove panels, you can use either the Remove method or the RemoveAt method if you know where the panel is located within the collection. 方法可讓您從集合中移除所有面板, 而不是Remove使用方法一次移除一個面板。 ClearThe Clear method enables you to remove all panels from the collection instead of using the Remove method to remove a single panel at a time.

除了用來加入和移除面板的方法和屬性之外, StatusBar.StatusBarPanelCollection也提供方法來尋找集合內的面板。In addition to methods and properties for adding and removing panels, the StatusBar.StatusBarPanelCollection also provides methods to find panels within the collection. Contains方法可讓您判斷面板是否為集合的成員。The Contains method enables you to determine whether a panel is a member of the collection. 一旦您知道面板位於集合內, 您就可以使用IndexOf方法來判斷面板在集合中的位置。Once you know that the panel is located within the collection, you can use the IndexOf method to determine where the panel is located within the collection.

建構函式

StatusBar.StatusBarPanelCollection(StatusBar)

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

屬性

Count

取得集合中的項目數目。Gets the number of items in the collection.

IsReadOnly

取得表示這個集合是否為唯讀的值。Gets a value indicating whether this collection is read-only.

Item[Int32]

取得或設定在指定索引處的 StatusBarPanelGets or sets the StatusBarPanel at the specified index.

Item[String]

從集合中取得具有指定索引鍵的項目。Gets an item with the specified key from the collection.

方法

Add(StatusBarPanel)

StatusBarPanel 加入集合。Adds a StatusBarPanel to the collection.

Add(String)

將含有指定文字的 StatusBarPanel 加入集合中。Adds a StatusBarPanel with the specified text to the collection.

AddRange(StatusBarPanel[])

StatusBarPanel 物件陣列加入集合。Adds an array of StatusBarPanel objects to the collection.

Clear()

移除集合的所有項目。Removes all items from the collection.

Contains(StatusBarPanel)

判斷指定的面板是否位於集合中。Determines whether the specified panel is located within the collection.

ContainsKey(String)

判斷集合是否包含具有指定索引鍵的 StatusBarPanelDetermines whether the collection contains a StatusBarPanel with the specified key.

Equals(Object)

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

(繼承來源 Object)
GetEnumerator()

傳回列舉程式,其可用來在項目集合中重複。Returns an enumerator to use to iterate through the item collection.

GetHashCode()

作為預設雜湊函數。Serves as the default hash function.

(繼承來源 Object)
GetType()

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

(繼承來源 Object)
IndexOf(StatusBarPanel)

傳回指定面板集合中的索引。Returns the index within the collection of the specified panel.

IndexOfKey(String)

傳回具有指定索引鍵之 StatusBarPanel 第一次出現的索引。Returns the index of the first occurrence of a StatusBarPanel with the specified key.

Insert(Int32, StatusBarPanel)

將指定的 StatusBarPanel 插入至集合中的指定索引處。Inserts the specified StatusBarPanel into the collection at the specified index.

MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
Remove(StatusBarPanel)

從集合移除指定的 StatusBarPanelRemoves the specified StatusBarPanel from the collection.

RemoveAt(Int32)

移除位在集合內指定索引上的 StatusBarPanelRemoves the StatusBarPanel located at the specified index within the collection.

RemoveByKey(String)

從集合中移除具有指定索引鍵的 StatusBarPanelRemoves the StatusBarPanel with the specified key from the collection.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

明確介面實作

ICollection.CopyTo(Array, Int32)

從目標陣列的指定索引開始,將 StatusBar.StatusBarPanelCollection 複製到相容的一維陣列中。Copies the StatusBar.StatusBarPanelCollection to a compatible one-dimensional array, starting at the specified index of the target array.

ICollection.IsSynchronized

取得值,表示是否同步化存取集合 (執行緒安全)。Gets a value indicating whether access to the collection is synchronized (thread safe).

ICollection.SyncRoot

取得物件,這個物件可以用來對集合進行同步存取。Gets an object that can be used to synchronize access to the collection.

IList.Add(Object)

StatusBarPanel 加入集合。Adds a StatusBarPanel to the collection.

IList.Contains(Object)

判斷指定的面板是否位於集合中。Determines whether the specified panel is located within the collection.

IList.IndexOf(Object)

傳回集合中指定之面板的索引。Returns the index of the specified panel within the collection.

IList.Insert(Int32, Object)

將指定的 StatusBarPanel 插入至集合中的指定索引處。Inserts the specified StatusBarPanel into the collection at the specified index.

IList.IsFixedSize

取得值,這個值表示集合的大小是否是固定的。Gets a value indicating whether the collection has a fixed size.

IList.Item[Int32]

在指定的索引位置上取得或設定項目。Gets or sets the element at the specified index.

IList.Remove(Object)

從集合移除指定的 StatusBarPanelRemoves the specified StatusBarPanel from the collection.

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryableConverts an IEnumerable to an IQueryable.

適用於

另請參閱