Bewerken

Delen via


Ways to Select a Windows Forms Button Control

A Windows Forms button can be selected in the following ways:

  • Use a mouse to click the button.

  • Invoke the button's Click event in code.

  • Move the focus to the button by pressing the TAB key, and then choose the button by pressing the SPACEBAR or ENTER.

  • Press the access key (ALT + the underlined letter) for the button. For more information about access keys, see How to: Create Access Keys for Windows Forms Controls.

  • If the button is the "accept" button of the form, pressing ENTER chooses the button, even if another control has the focus — except if that other control is another button, a multi-line text box, or a custom control that traps the enter key.

  • If the button is the "cancel" button of the form, pressing ESC chooses the button, even if another control has the focus.

  • Call the PerformClick method to select the button programmatically.

See also