Sdílet prostřednictvím


StatusBar.StatusBarPanelCollection Třída

Definice

Upozornění

StatusBar is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use StatusStrip instead.

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
[System.ComponentModel.ListBindable(false)]
[System.ComponentModel.Browsable(false)]
[System.Obsolete("`StatusBar` is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use `StatusStrip` instead.", false, DiagnosticId="WFDEV006", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
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
[<System.ComponentModel.ListBindable(false)>]
[<System.ComponentModel.Browsable(false)>]
[<System.Obsolete("`StatusBar` is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use `StatusStrip` instead.", false, DiagnosticId="WFDEV006", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
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. Jedna z pojmenovaných StatusBarPanelpanel1a zobrazuje stavový text aplikace. Druhý StatusBarPanel, 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 k Add 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 souboru 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 objektů a přiřadíte ho StatusBarPanel metodě AddRange . 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. Tato Clear metoda umožňuje odebrat všechny panely z kolekce namí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ů StatusBar.StatusBarPanelCollection poskytuje také metody pro vyhledání panelů v kolekci. Tato Contains metoda umožňuje určit, zda 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

Name Description
StatusBar.StatusBarPanelCollection(StatusBar)
Zastaralé.

Inicializuje novou instanci StatusBar.StatusBarPanelCollection třídy.

Vlastnosti

Name Description
Count
Zastaralé.

Získá počet položek v kolekci.

IsReadOnly
Zastaralé.

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

Item[Int32]
Zastaralé.

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

Item[String]
Zastaralé.

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

Metody

Name Description
Add(StatusBarPanel)
Zastaralé.

StatusBarPanel Přidá do kolekce.

Add(String)
Zastaralé.

Přidá do kolekce zadaný StatusBarPanel text.

AddRange(StatusBarPanel[])
Zastaralé.

Přidá do kolekce pole StatusBarPanel objektů.

Clear()
Zastaralé.

Odebere všechny položky z kolekce.

Contains(StatusBarPanel)
Zastaralé.

Určuje, zda je zadaný panel umístěn v kolekci.

ContainsKey(String)
Zastaralé.

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

Equals(Object)
Zastaralé.

Určuje, zda je zadaný objekt roven aktuálnímu objektu.

(Zděděno od Object)
GetEnumerator()
Zastaralé.

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

GetHashCode()
Zastaralé.

Slouží jako výchozí funkce hash.

(Zděděno od Object)
GetType()
Zastaralé.

Získá Type aktuální instance.

(Zděděno od Object)
IndexOf(StatusBarPanel)
Zastaralé.

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

IndexOfKey(String)
Zastaralé.

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

Insert(Int32, StatusBarPanel)
Zastaralé.

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

MemberwiseClone()
Zastaralé.

Vytvoří mělkou kopii aktuálního Object.

(Zděděno od Object)
Remove(StatusBarPanel)
Zastaralé.

Odebere zadanou StatusBarPanel položku z kolekce.

RemoveAt(Int32)
Zastaralé.

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

RemoveByKey(String)
Zastaralé.

Odebere ze StatusBarPanel kolekce zadaný klíč.

ToString()
Zastaralé.

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

(Zděděno od Object)

Explicitní implementace rozhraní

Name Description
ICollection.CopyTo(Array, Int32)
Zastaralé.

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

ICollection.IsSynchronized
Zastaralé.

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

ICollection.SyncRoot
Zastaralé.

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.

Zastaralé.

StatusBarPanel Přidá do kolekce.

IList.Contains(Object)
Zastaralé.

Určuje, zda je zadaný panel umístěn v kolekci.

IList.IndexOf(Object)
Zastaralé.

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

IList.Insert(Int32, Object)
Zastaralé.

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

IList.IsFixedSize
Zastaralé.

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

IList.Item[Int32]
Zastaralé.

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

IList.Remove(Object)
Zastaralé.

Odebere zadanou StatusBarPanel položku z kolekce.

Metody rozšíření

Name Description
AsParallel(IEnumerable)
Zastaralé.

Umožňuje paralelizaci dotazu.

AsQueryable(IEnumerable)
Zastaralé.

Převede IEnumerable na IQueryable.

Cast<TResult>(IEnumerable)
Zastaralé.

Přetypuje prvky IEnumerable na zadaný typ.

OfType<TResult>(IEnumerable)
Zastaralé.

Filtruje prvky IEnumerable na základě zadaného typu.

Platí pro

Viz také