StatusBar.StatusBarPanelCollection StatusBar.StatusBarPanelCollection StatusBar.StatusBarPanelCollection StatusBar.StatusBarPanelCollection Class

定義

代表 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.StatusBarPanelCollectionStatusBar.StatusBarPanelCollectionStatusBar.StatusBarPanelCollectionStatusBar.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屬性來存取Add方法StatusBar.StatusBarPanelCollection若要將面板加入StatusBarThe 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. 此範例也會使用AutoSizeBorderStyleToolTipText,以及Text屬性,以初始化StatusBarPanel物件。The example also uses the AutoSize, BorderStyle, ToolTipText, and Text properties to initialize the StatusBarPanel objects. 這個範例假設在範例中所定義的方法是定義和呼叫的建構函式從FormThis 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.StatusBarPanelCollection類別會儲存在顯示的面板StatusBarThe StatusBar.StatusBarPanelCollection class stores the panels displayed in the StatusBar. 集合中的每個物件是的執行個體StatusBarPanel類別定義的顯示特性和行為中所顯示的面板StatusBarEach 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. Clear方法可讓您移除而不是使用集合中的所有面板Remove方法一次都移除一個單一的面板。The 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(StatusBar) StatusBar.StatusBarPanelCollection(StatusBar) StatusBar.StatusBarPanelCollection(StatusBar)

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

屬性

Count Count Count Count

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

IsReadOnly IsReadOnly IsReadOnly IsReadOnly

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

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

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

Item[String] Item[String] Item[String] Item[String]

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

方法

Add(StatusBarPanel) Add(StatusBarPanel) Add(StatusBarPanel) Add(StatusBarPanel)

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

Add(String) Add(String) Add(String) Add(String)

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

AddRange(StatusBarPanel[]) AddRange(StatusBarPanel[]) AddRange(StatusBarPanel[]) AddRange(StatusBarPanel[])

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

Clear() Clear() Clear() Clear()

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

Contains(StatusBarPanel) Contains(StatusBarPanel) Contains(StatusBarPanel) Contains(StatusBarPanel)

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

ContainsKey(String) ContainsKey(String) ContainsKey(String) ContainsKey(String)

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

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

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

(Inherited from Object)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

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

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

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

(Inherited from Object)
GetType() GetType() GetType() GetType()

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

(Inherited from Object)
IndexOf(StatusBarPanel) IndexOf(StatusBarPanel) IndexOf(StatusBarPanel) IndexOf(StatusBarPanel)

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

IndexOfKey(String) IndexOfKey(String) IndexOfKey(String) IndexOfKey(String)

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

Insert(Int32, StatusBarPanel) Insert(Int32, StatusBarPanel) Insert(Int32, StatusBarPanel) Insert(Int32, StatusBarPanel)

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

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

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

(Inherited from Object)
Remove(StatusBarPanel) Remove(StatusBarPanel) Remove(StatusBarPanel) Remove(StatusBarPanel)

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

RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32)

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

RemoveByKey(String) RemoveByKey(String) RemoveByKey(String) RemoveByKey(String)

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

ToString() ToString() ToString() ToString()

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

(Inherited from Object)

明確介面實作

ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) 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 ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized

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

ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot

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

IList.Add(Object) IList.Add(Object) IList.Add(Object) IList.Add(Object)

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

IList.Contains(Object) IList.Contains(Object) IList.Contains(Object) IList.Contains(Object)

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

IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object)

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

IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object)

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

IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize

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

IList.Item[Int32] IList.Item[Int32] IList.Item[Int32] IList.Item[Int32]

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

IList.Remove(Object) IList.Remove(Object) IList.Remove(Object) IList.Remove(Object)

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

Extension Methods

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

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

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

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

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

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

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

將轉換IEnumerableIQueryableConverts an IEnumerable to an IQueryable.

適用於

另請參閱