Assembly : System.Windows.Forms (dans system.windows.forms.dll)
Syntaxe<ComVisibleAttribute(True)> _ <ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _ Public Class Button Inherits ButtonBase Implements IButtonControl
Dim instance As Button
[ComVisibleAttribute(true)] [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] public class Button : ButtonBase, IButtonControl
[ComVisibleAttribute(true)] [ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] public ref class Button : public ButtonBase, IButtonControl
/** @attribute ComVisibleAttribute(true) */ /** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ public class Button extends ButtonBase implements IButtonControl
ComVisibleAttribute(true) ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) public class Button extends ButtonBase implements IButtonControl
NotesButton peut être sélectionné grâce à un clic de souris, à la touche ENTRÉE ou à la BARRE D'ESPACEMENT si le bouton a le focus.
Définissez la propriété AcceptButton ou CancelButton de Form pour permettre aux utilisateurs de sélectionner un bouton en appuyant sur la touche ENTRÉE ou ÉCHAP même si le bouton n'a pas le focus. Cela permet au formulaire d'avoir le comportement d'une boîte de dialogue.
Lorsque vous affichez un formulaire à l'aide de la méthode ShowDialog, vous pouvez utiliser la propriété DialogResult d'un bouton pour spécifier la valeur de retour de ShowDialog.
Vous pouvez modifier l'apparence du bouton. Par exemple, pour lui donner une forme à deux dimensions propre à une présentation Web, affectez FlatStyle.Flat à la propriété FlatStyle. FlatStyle.Popup peut également être affecté à la propriété FlatStyle, lui conférant ainsi une forme à deux dimensions jusqu'au passage du pointeur sur le bouton ; le bouton reprend ensuite la forme d'un bouton Windows standard.
Remarque |
|---|
| Si le contrôle ayant le focus accepte de traiter une pression sur la touche ENTRÉE, Button ne se charge alors pas de son traitement. Par exemple, si un TextBox multiligne ou tout autre bouton a le focus, ce contrôle traite alors la pression sur la touche ENTRÉE et non la sélection du bouton d'acceptation. |
ExempleL'exemple de code suivant crée un Button, affecte DialogResult.OK à sa propriété DialogResult, puis l'ajoute à un Form.
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 'InitializeMyButton
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: 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.set_DialogResult(get_DialogResult().OK); // Add the button to the form. get_Controls().Add(button1); } //InitializeMyButton
private function InitializeMyButton() { // Create and initialize a Button. var button1 : Button = new Button(); // Set the button to return a value of OK when clicked. button1.DialogResult = System.Windows.Forms.DialogResult.OK; // Add the button to the form. Controls.Add(button1); }
Hiérarchie d'héritageSystem.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.ButtonBase
System.Windows.Forms.Button
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.
Remarque
Outils (masquer)
S'enregistrer
Liste des Membres
Qui est en ligne?
FAQ