This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!
Selecting a Button Control Programmatically
A Win Forms button can be selected programmatically 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 shortcut (ALT + the underlined letter) for the button. For more information on access keys, see Creating Access Keys for Controls.
- If the button is the “accept” button of the form, pressing ENTER chooses the button, even if another control has the focus. For more information, see Designating a Button As the Accept Button.
- If the button is the “cancel” button of the form, then pressing ESC chooses the button, even if another control has the focus. For more information, see Designating a Button As the Cancel Button.
See Also
Button Class | Button Control | Responding to Button Clicks