StatusBar.StatusBarPanelCollection Klasa

Definicja

Reprezentuje kolekcję paneli w kontrolce StatusBar .

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
Dziedziczenie
StatusBar.StatusBarPanelCollection
Atrybuty
Implementuje

Przykłady

Poniższy przykład kodu tworzy kontrolkę StatusBar w formularzu i dodaje dwa StatusBarPanel obiekty. Jeden z elementów StatusBarPanelo nazwie panel1wyświetla tekst stanu aplikacji. Drugi StatusBarPanel, o nazwie panel2, wyświetla bieżącą datę i używa ToolTipText właściwości StatusBarPanel klasy do wyświetlenia bieżącej godziny. W przykładzie użyto ShowPanels właściwości , aby upewnić się, że panele są wyświetlane zamiast panelu standardowego i używa właściwości oraz Panels właściwości w celu uzyskania dostępu do Add metody StatusBar.StatusBarPanelCollection w celu dodania paneli do obiektu StatusBar. W przykładzie użyto AutoSizerównież właściwości , BorderStyle, ToolTipTexti Text w celu zainicjowania StatusBarPanel obiektów. W tym przykładzie przyjęto założenie, że metoda zdefiniowana w przykładzie jest zdefiniowana i wywoływana z konstruktora Formklasy .

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

Uwagi

Klasa StatusBar.StatusBarPanelCollection przechowuje panele wyświetlane w obiekcie StatusBar. Każdy obiekt w kolekcji jest wystąpieniem StatusBarPanel klasy, które definiuje charakterystykę wyświetlania i zachowania panelu wyświetlanego w obiekcie StatusBar.

Istnieje wiele sposobów dodawania paneli do kolekcji. Metoda Add umożliwia dodanie pojedynczego panelu do kolekcji. Aby dodać kilka paneli do kolekcji, należy utworzyć tablicę StatusBarPanel obiektów i przypisać ją do AddRange metody . Jeśli chcesz wstawić panel w określonej lokalizacji w kolekcji, możesz użyć Insert metody . Aby usunąć panele, możesz użyć Remove metody lub RemoveAt metody, jeśli wiesz, gdzie panel znajduje się w kolekcji. Metoda Clear umożliwia usunięcie wszystkich paneli z kolekcji zamiast używania Remove metody w celu usunięcia pojedynczego panelu naraz.

Oprócz metod i właściwości dodawania i usuwania paneli, StatusBar.StatusBarPanelCollection udostępnia również metody znajdowania paneli w kolekcji. Metoda Contains umożliwia określenie, czy panel jest członkiem kolekcji. Gdy wiesz, że panel znajduje się w kolekcji, możesz użyć IndexOf metody , aby określić, gdzie panel znajduje się w kolekcji.

Konstruktory

StatusBar.StatusBarPanelCollection(StatusBar)

Inicjuje nowe wystąpienie klasy StatusBar.StatusBarPanelCollection.

Właściwości

Count

Pobiera liczbę elementów w kolekcji.

IsReadOnly

Pobiera wartość wskazującą, czy ta kolekcja jest tylko do odczytu.

Item[Int32]

Pobiera lub ustawia wartość StatusBarPanel w określonym indeksie.

Item[String]

Pobiera element z określonym kluczem z kolekcji.

Metody

Add(StatusBarPanel)

Dodaje element StatusBarPanel do kolekcji.

Add(String)

Dodaje obiekt StatusBarPanel z określonym tekstem do kolekcji.

AddRange(StatusBarPanel[])

Dodaje tablicę StatusBarPanel obiektów do kolekcji.

Clear()

Usuwa wszystkie elementy z kolekcji.

Contains(StatusBarPanel)

Określa, czy określony panel znajduje się w kolekcji.

ContainsKey(String)

Określa, czy kolekcja zawiera StatusBarPanel element z określonym kluczem.

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetEnumerator()

Zwraca moduł wyliczający używany do iterowania po kolekcji elementów.

GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
IndexOf(StatusBarPanel)

Zwraca indeks w kolekcji określonego panelu.

IndexOfKey(String)

Zwraca indeks pierwszego wystąpienia obiektu StatusBarPanel z określonym kluczem.

Insert(Int32, StatusBarPanel)

Wstawia określony StatusBarPanel element do kolekcji w określonym indeksie.

MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
Remove(StatusBarPanel)

Usuwa określony StatusBarPanel element z kolekcji.

RemoveAt(Int32)

Usuwa obiekt StatusBarPanel znajdujący się w określonym indeksie w kolekcji.

RemoveByKey(String)

Usuwa element StatusBarPanel z określonym kluczem z kolekcji.

ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Jawne implementacje interfejsu

ICollection.CopyTo(Array, Int32)

Kopiuje StatusBar.StatusBarPanelCollection element do zgodnej tablicy jednowymiarowej, zaczynając od określonego indeksu tablicy docelowej.

ICollection.IsSynchronized

Pobiera wartość wskazującą, czy dostęp do kolekcji jest synchronizowany (bezpieczny wątek).

ICollection.SyncRoot

Pobiera obiekt, który może służyć do synchronizowania dostępu do kolekcji.

IList.Add(Object)

Ten interfejs API obsługuje infrastrukturę produktu i nie jest przeznaczony do użycia bezpośrednio z poziomu kodu.

Dodaje element StatusBarPanel do kolekcji.

IList.Contains(Object)

Określa, czy określony panel znajduje się w kolekcji.

IList.IndexOf(Object)

Zwraca indeks określonego panelu w kolekcji.

IList.Insert(Int32, Object)

Wstawia określony StatusBarPanel element do kolekcji w określonym indeksie.

IList.IsFixedSize

Pobiera wartość wskazującą, czy kolekcja ma stały rozmiar.

IList.Item[Int32]

Pobiera lub ustawia element pod określonym indeksem.

IList.Remove(Object)

Usuwa określony StatusBarPanel element z kolekcji.

Metody rozszerzania

Cast<TResult>(IEnumerable)

Rzutuje elementy elementu IEnumerable na określony typ.

OfType<TResult>(IEnumerable)

Filtruje elementy IEnumerable elementu na podstawie określonego typu.

AsParallel(IEnumerable)

Umożliwia równoległość zapytania.

AsQueryable(IEnumerable)

Konwertuje element IEnumerable na .IQueryable

Dotyczy

Zobacz też