Button Constructeur

Définition

Initialise une nouvelle instance de la classe Button.

public:
 Button();
public Button ();
Public Sub New ()

Exemples

L’exemple de code suivant crée un Button, définit sa DialogResult propriété sur la OK valeur de DialogResult, et l’ajoute à un Form.

private:
   void InitializeMyButton()
   {
      // Create and initialize a Button.
      Button^ button1 = gcnew Button;
      
      // Set the button to return a value of OK when clicked.
      button1->DialogResult = ::DialogResult::OK;
      
      // Add the button to the form.
      Controls->Add( button1 );
   }
private void InitializeMyButton()
 {
    // Create and initialize a Button.
    Button button1 = new Button();
 
    // Set the button to return a value of OK when clicked.
    button1.DialogResult = DialogResult.OK;
 
    // Add the button to the form.
    Controls.Add(button1);
 }
Private Sub InitializeMyButton()
    ' Create and initialize a Button.
    Dim button1 As New Button()
    
    ' Set the button to return a value of OK when clicked.
    button1.DialogResult = DialogResult.OK
    
    ' Add the button to the form.
    Controls.Add(button1)
End Sub

Remarques

Par défaut, l’affichage n’affiche Button aucune légende. Pour spécifier le texte de légende, définissez la Text propriété.

S’applique à

Voir aussi