Assembly : System.Windows.Forms (dans system.windows.forms.dll)
Syntaxe<ComVisibleAttribute(True)> _ <ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _ Public Class StatusBar Inherits Control
Dim instance As StatusBar
[ComVisibleAttribute(true)] [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] public class StatusBar : Control
[ComVisibleAttribute(true)] [ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] public ref class StatusBar : public Control
/** @attribute ComVisibleAttribute(true) */ /** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ public class StatusBar extends Control
ComVisibleAttribute(true) ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) public class StatusBar extends Control
NotesEn règle générale, un contrôle StatusBar est constitué d'objets StatusBarPanel, dont chacun affiche du texte et/ou une icône. Vous pouvez aussi faire en sorte que les panneaux owner-drawn puissent fournir des panneaux personnalisés tels qu'une barre de progression ou une série d'images qui indiquent l'état de votre application. Généralement, un contrôle StatusBar affiche des informations sur un objet affiché dans Form, les composants de cet objet ou les informations contextuelles relatives au fonctionnement de cet objet au sein de votre application.
Le contrôle StatusBar fournit différentes propriétés qui vous permettent de personnaliser l'apparence du contrôle. Si StatusBar est affiché sur un formulaire qui peut être redimensionné, vous pouvez utiliser la propriété SizingGrip pour afficher une poignée de redimensionnement dans le coin inférieur droit du formulaire pour indiquer aux utilisateurs que le formulaire peut être redimensionné. La propriété ShowPanels vous permet d'afficher des panneaux dans votre StatusBar ou d'afficher uniquement la valeur de la propriété Text du contrôle.
Le tableau StatusBar n'a pas de panneaux. Pour ajouter des panneaux à StatusBar vous pouvez utiliser la méthode Add de la classe StatusBar.StatusBarPanelCollection qui est accessible au travers de la propriété Panels du contrôle. Vous pouvez utiliser l'objet StatusBar.StatusBarPanelCollection fourni au travers de la propriété Panels pour supprimer les panneaux du contrôle et accéder à un StatusBarPanel spécifique pour manipuler le panneau.
Si vous voulez déterminer le moment où un objet StatusBarPanel dans un contrôle StatusBar est activé par un clic, vous pouvez créer un gestionnaire d'événements pour l'événement PanelClick. Pour effectuer des opérations owner-draw sur un panneau, vous pouvez créer un gestionnaire d'événements pour l'événement DrawItem. Les données d'événement passées au gestionnaire d'événements fournissent des informations sur le panneau à dessiner et un objet Graphics à utiliser pour exécuter les tâches de dessin.
Lorsque vous créez une instance de StatusBar, les valeurs initiales sont affectées aux propriétés de lecture/écriture. Pour obtenir la liste de ces valeurs, consultez le constructeur StatusBar.
ExempleL'exemple de code suivant crée un contrôle StatusBar sur un formulaire et ajoute deux objets StatusBarPanel. Un des objets StatusBarPanel, nommé panel1, affiche le texte d'état pour une application. Le deuxième objet StatusBarPanel, nommé panel2, affiche la date actuelle et utilise la propriété ToolTipText de la classe StatusBarPanel pour afficher l'heure actuelle. L'exemple utilise la propriété ShowPanels pour garantir l'affichage des panneaux à la place d'un panneau standard et il utilise la propriété Panels pour accéder à la méthode Add de StatusBar.StatusBarPanelCollection pour ajouter les panneaux à StatusBar. L'exemple utilise également les propriétés AutoSize, BorderStyle, ToolTipText et Text pour initialiser les objets StatusBarPanel. Cet exemple requiert que la méthode définie dans l'exemple soit définie et appelée à partir du constructeur d'un Form.
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
Hiérarchie d'héritageSystem.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.StatusBar
Sécurité des threads
Plates-formesWindows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile pour Pocket PC, Windows Server 2003, Windows XP Édition Media Center, Windows XP Professionnel Édition x64, Windows XP SP2, Windows XP Starter Edition
Le .NET Framework ne prend pas en charge toutes les versions de chaque plate-forme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise.
Informations de version
Outils (masquer)
S'enregistrer
Liste des Membres
Qui est en ligne?
FAQ