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)

向集合中添加包含指定文本的 StatusBarPanelAdds 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 的浅表副本。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.

扩展方法

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.

适用于

另请参阅