StatusBar.StatusBarPanelCollection Třída

Definice

Představuje kolekci panelů v ovládacím StatusBar prvku.

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
Dědičnost
StatusBar.StatusBarPanelCollection
Atributy
Implementuje

Příklady

Následující příklad kódu vytvoří StatusBar ovládací prvek ve formuláři a přidá dva StatusBarPanel objekty. Jeden z pojmenovaných panel1výrazů StatusBarPanelzobrazuje stavový text aplikace. StatusBarPanelDruhá , pojmenovaná panel2, zobrazí aktuální datum a používá ToolTipText vlastnost StatusBarPanel třídy k zobrazení aktuálního času. Příklad používá ShowPanels vlastnost k zajištění, aby se panely zobrazovaly místo standardního panelu, a používá a Panels vlastnost pro přístup Add k metodě StatusBar.StatusBarPanelCollection přidání panelů do StatusBar. Příklad také používá AutoSize, , BorderStyleToolTipTexta Text vlastnosti inicializovat StatusBarPanel objekty. Tento příklad předpokládá, že metoda definovaná v příkladu je definována a volána z konstruktoru objektu 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

Poznámky

Třída StatusBar.StatusBarPanelCollection ukládá panely zobrazené v sadě StatusBar. Každý objekt v kolekci je instance StatusBarPanel třídy, která definuje vlastnosti zobrazení a chování panelu zobrazeného v objektu StatusBar.

Existuje několik způsobů, jak přidat panely do kolekce. Metoda Add poskytuje možnost přidat do kolekce jeden panel. Pokud chcete do kolekce přidat několik panelů, vytvoříte pole StatusBarPanel objektů a přiřadíte ho AddRange metodě. Pokud chcete vložit panel do konkrétního umístění v kolekci, můžete použít metodu Insert . Pokud chcete odebrat panely, můžete použít metodu Remove nebo metodu RemoveAt , pokud víte, kde se panel nachází v kolekci. Metoda Clear umožňuje odebrat všechny panely z kolekce místo použití Remove metody k odebrání jednoho panelu najednou.

Kromě metod a vlastností pro přidávání a odebírání panelů poskytuje také metody pro vyhledání panelů StatusBar.StatusBarPanelCollection v kolekci. Metoda Contains umožňuje určit, jestli je panel členem kolekce. Jakmile víte, že se panel nachází v kolekci, můžete pomocí IndexOf metody určit, kde se panel nachází v kolekci.

Konstruktory

StatusBar.StatusBarPanelCollection(StatusBar)

Inicializuje novou instanci StatusBar.StatusBarPanelCollection třídy.

Vlastnosti

Count

Získá počet prvků v kolekci.

IsReadOnly

Získá hodnotu označující, zda je tato kolekce jen pro čtení.

Item[Int32]

Získá nebo nastaví v zadaném indexu StatusBarPanel .

Item[String]

Získá položku se zadaným klíčem z kolekce.

Metody

Add(StatusBarPanel)

Přidá do kolekce.StatusBarPanel

Add(String)

Přidá do StatusBarPanel kolekce zadaný text.

AddRange(StatusBarPanel[])

Přidá do kolekce pole StatusBarPanel objektů.

Clear()

Odebere všechny položky z kolekce.

Contains(StatusBarPanel)

Určuje, zda se zadaný panel nachází v kolekci.

ContainsKey(String)

Určuje, zda kolekce obsahuje StatusBarPanel zadaný klíč.

Equals(Object)

Určí, zda se zadaný objekt rovná aktuálnímu objektu.

(Zděděno od Object)
GetEnumerator()

Vrátí enumerátor, který se použije k iteraci v kolekci položek.

GetHashCode()

Slouží jako výchozí funkce hash.

(Zděděno od Object)
GetType()

Type Získá aktuální instanci.

(Zděděno od Object)
IndexOf(StatusBarPanel)

Vrátí index v kolekci zadaného panelu.

IndexOfKey(String)

Vrátí index prvního výskytu zadaného StatusBarPanel klíče.

Insert(Int32, StatusBarPanel)

Vloží zadaný StatusBarPanel do kolekce do zadaného indexu.

MemberwiseClone()

Vytvoří použádnou kopii aktuálního souboru Object.

(Zděděno od Object)
Remove(StatusBarPanel)

Odebere zadanou StatusBarPanel z kolekce.

RemoveAt(Int32)

Odebere StatusBarPanel umístění v zadaném indexu v kolekci.

RemoveByKey(String)

Odebere StatusBarPanel ze kolekce zadaný klíč.

ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)

Explicitní implementace rozhraní

ICollection.CopyTo(Array, Int32)

Zkopíruje StatusBar.StatusBarPanelCollection do kompatibilního jednorozměrného pole počínaje zadaným indexem cílového pole.

ICollection.IsSynchronized

Získá hodnotu označující, zda je přístup k kolekci synchronizován (bezpečné vlákno).

ICollection.SyncRoot

Získá objekt, který lze použít k synchronizaci přístupu k kolekci.

IList.Add(Object)

Toto rozhraní API podporuje produktovou infrastrukturu a není určené k použití přímo z uživatelského kódu.

StatusBarPanel Přidá do kolekce.

IList.Contains(Object)

Určuje, zda se zadaný panel nachází v kolekci.

IList.IndexOf(Object)

Vrátí index zadaného panelu v kolekci.

IList.Insert(Int32, Object)

Vloží zadaný StatusBarPanel objekt do kolekce v zadaném indexu.

IList.IsFixedSize

Získá hodnotu určující, zda kolekce má pevnou velikost.

IList.Item[Int32]

Získá nebo nastaví prvek u zadaného indexu.

IList.Remove(Object)

Odebere zadanou StatusBarPanel z kolekce.

Metody rozšíření

Cast<TResult>(IEnumerable)

Přetypuje prvky zadaného IEnumerable typu.

OfType<TResult>(IEnumerable)

Filtruje prvky IEnumerable založené na zadaném typu.

AsParallel(IEnumerable)

Umožňuje paralelizaci dotazu.

AsQueryable(IEnumerable)

Převede na IEnumerable IQueryable.

Platí pro

Viz také