StatusBar, classe (System.Windows.Forms)

Bibliothèque de classes .NET Framework 
StatusBar, classe 

Représente un contrôle de barre d'état Windows. Bien que ToolStripStatusLabel remplace et ajoute des fonctionnalités au contrôle StatusBar des versions antérieures, StatusBar est conservé pour la compatibilité descendante et l'utilisation future si tel est votre choix.

Espace de noms : System.Windows.Forms
Assembly : System.Windows.Forms (dans system.windows.forms.dll)

SyntaxeSyntaxe


Visual Basic (Déclaration)
<ComVisibleAttribute(True)> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
Public Class StatusBar
    Inherits Control


Visual Basic (Utilisation)
Dim instance As StatusBar


C#
[ComVisibleAttribute(true)] 
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
public class StatusBar : Control


C++
[ComVisibleAttribute(true)] 
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
public ref class StatusBar : public Control


J#
/** @attribute ComVisibleAttribute(true) */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
public class StatusBar extends Control


JScript
ComVisibleAttribute(true) 
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
public class StatusBar extends Control
NotesNotes

En 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.

ExempleExemple

L'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.



Visual Basic
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


C#
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);
}


C++
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 );
   }


J#
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éritageHiérarchie d'héritage
System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Windows.Forms.Control
        System.Windows.Forms.StatusBar
Sécurité des threadsSécurité des threads
Les membres statiques publics (Shared en Visual Basic) de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.
Plates-formesPlates-formes

Windows 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 versionInformations de version

.NET Framework

Prise en charge dans : 2.0, 1.1, 1.0

.NET Compact Framework

Prise en charge dans : 2.0, 1.0
Voir aussiVoir aussi

Ces informations proviennent du site de http://msdn2.microsoft.com
Source de cette page : http://msdn2.microsoft.com/fr-fr/library/system.windows.forms.statusbar.aspx

Réseaux sociaux

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.

 

Nuage de mots clés

9 mots clés dont 0 définis manuellement (plus d'information...).

Avertissement

Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.

 

Astuce pour imprimer les couleurs des cellules de tableaux : http://www.gaudry.be/ast-rf-450.html
Aucun commentaire pour cette page

© Ce document issu de l′infobrol est enregistré sous le certificat Cyber PrInterDeposit Digital Numbertection. Enregistrement IDDN n° 5329-6159
Document créé le 30/10/06 02:25, dernière modification le Vendredi 17 Juin 2011, 12:11
Source du document imprimé : http://www.gaudry.be/dotnet-rf-system.windows.forms.statusbar.html Document affiché 1 fois ce mois de Juin.
St.Gaudry©07.01.02
Outils (masquer)
||
Recherche (afficher)
Recherche :

Utilisateur (masquer)
Apparence (afficher)
Stats (afficher)
15832 documents
452 astuces.
549 niouzes.
3099 definitions.
447 membres.
8115 messages.

Document genere en :
0,35 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
Il y a deux méthodes pour écrire des programmes sans erreurs. Mais il n’y a que la troisième qui marche

Anonyme
 
l'infobrol
Nous sommes le Vendredi 01 Juin 2012, 05:44, toutes les heures sont au format GMT+1.00 Heure, heure d'été (+1)