Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Ruft die im Steuerelement enthaltene Auflistung von StatusBar-Bereichen ab.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Syntax
'Declaration
<LocalizableAttribute(True)> _
Public ReadOnly Property Panels As StatusBarPanelCollection
'Usage
Dim instance As StatusBar
Dim value As StatusBarPanelCollection
value = instance.Panels
[LocalizableAttribute(true)]
public StatusBarPanelCollection Panels { get; }
[LocalizableAttribute(true)]
public:
property StatusBarPanelCollection^ Panels {
StatusBarPanelCollection^ get ();
}
/** @property */
public StatusBarPanelCollection get_Panels ()
public function get Panels () : StatusBarPanelCollection
Eigenschaftenwert
Eine StatusBar.StatusBarPanelCollection, die die StatusBarPanel-Objekte des StatusBar-Steuerelements enthält.
Hinweise
Mit dem StatusBar-Steuerelement kann eine Reihe von Bereichen angezeigt werden, in denen Benutzern Informationen angezeigt werden. Ein Bereich kann z. B. die aktuelle Uhrzeit oder den Fortschritt beim Downloaden einer Datei anzeigen. Jeder im StatusBar-Steuerelement angezeigte Bereich ist eine Instanz der StatusBarPanel-Klasse. Die Panels-Eigenschaft ermöglicht das Abrufen eines Verweises auf die Auflistung von StatusBarPanel-Objekten, die gegenwärtig im StatusBar-Steuerelement gespeichert sind. Mithilfe dieses Verweises können Sie Bereiche hinzufügen und entfernen, auf einen bestimmten Bereich in der Auflistung zugreifen sowie die Anzahl der Bereiche im StatusBar-Steuerelement abrufen. Weitere Informationen über die Aufgaben, die mit der Auflistung der Bereiche durchgeführt werden können, finden Sie unter den Referenzthemen zur StatusBar.StatusBarPanelCollection-Klasse.
Beispiel
Im folgenden Codebeispiel werden ein StatusBar-Steuerelement in einem Formular erstellt und zwei StatusBarPanel-Objekte hinzugefügt. Eines der StatusBarPanel-Objekte mit dem Namen panel1 zeigt den Statustext für eine Anwendung an. Das zweite StatusBarPanel-Objekt mit dem Namen panel2 zeigt das aktuelle Datum und mithilfe der ToolTipText-Eigenschaft der StatusBarPanel-Klasse die aktuelle Uhrzeit an. Im Beispiel wird mithilfe der ShowPanels-Eigenschaft sichergestellt, dass die Bereiche anstelle eines Standardbereichs angezeigt werden, und es wird mithilfe der Panels-Eigenschaft auf die Add-Methode der StatusBar.StatusBarPanelCollection zugegriffen, um der StatusBar Bereiche hinzuzufügen. Außerdem werden in dem Beispiel die Eigenschaften AutoSize, BorderStyle, ToolTipText und Text zum Initialisieren der StatusBarPanel-Objekte verwendet. Für dieses Beispiel ist es erforderlich, dass die im Beispiel verwendete Methode im Konstruktor eines Form definiert und aufgerufen wird.
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
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:
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.set_BorderStyle(StatusBarPanelBorderStyle.Sunken);
// Initialize the text of the panel.
panel1.set_Text("Ready...");
// Set the AutoSize property to use all remaining space on the StatusBar.
panel1.set_AutoSize(StatusBarPanelAutoSize.Spring);
// Display the second panel with a raised border style.
panel2.set_BorderStyle(StatusBarPanelBorderStyle.Raised);
// Create ToolTip text that displays the time the application was started.
panel2.set_ToolTipText("Started: " + System.DateTime.get_Now().ToShortTimeString());
// Set the text of the panel to the current date.
panel2.set_Text(System.DateTime.get_Today().ToLongDateString());
// Set the AutoSize property to size the panel to the size of the
// contents.
panel2.set_AutoSize(StatusBarPanelAutoSize.Contents);
// Display panels in the StatusBar control.
statusBar1.set_ShowPanels(true);
// Add both panels to the StatusBarPanelCollection of the StatusBar.
statusBar1.get_Panels().Add(panel1);
statusBar1.get_Panels().Add(panel2);
// Add the StatusBar to the form.
this.get_Controls().Add(statusBar1);
} //CreateMyStatusBar
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
StatusBar-Klasse
StatusBar-Member
System.Windows.Forms-Namespace
StatusBar.StatusBarPanelCollection
StatusBarPanel