StatusBar.StatusBarPanelCollection 类     
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示 StatusBar 控件中的面板的集合。
public: ref class StatusBar::StatusBarPanelCollection : System::Collections::IListpublic class StatusBar.StatusBarPanelCollection : System.Collections.IList[System.ComponentModel.ListBindable(false)]
public class StatusBar.StatusBarPanelCollection : System.Collections.IListtype StatusBar.StatusBarPanelCollection = class
    interface IList
    interface ICollection
    interface IEnumerable[<System.ComponentModel.ListBindable(false)>]
type StatusBar.StatusBarPanelCollection = class
    interface IList
    interface ICollection
    interface IEnumerablePublic Class StatusBar.StatusBarPanelCollection
Implements IList- 继承
- 
				StatusBar.StatusBarPanelCollection
- 属性
- 实现
示例
下面的代码示例在窗体上创建一个控件,并添加两StatusBarPanel个StatusBar对象。 其中一个名为StatusBarPanelpanel1,显示应用程序的状态文本。 第二 StatusBarPanel个,命名 panel2,显示当前日期,并使用 ToolTipText 类的属性 StatusBarPanel 显示当前时间。 该示例使用ShowPanels该属性来确保显示面板而不是标准面板,并且该属性用于Panels访问Add将面板添加到StatusBar其中的方法StatusBar.StatusBarPanelCollection。 该示例还使用 AutoSize、BorderStyle和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。 |