The correct answer is: B. Form.defaultButton=button1
The default button is the button that is automatically selected when the user presses Enter. To designate a default button, you use the Form.defaultButton
property. The value of this property is a reference to the button that you want to be the default button.
The other options are incorrect because:
Form.default
is not a valid property.Form.AcceptButton
is a valid property, but it is used to designate the button that is clicked when the user presses the Enter key to accept a dialog box.Form.focused
is a valid property, but it is used to designate the button that is currently in focus.
Here is an example of how to designate a default button:
“`
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
// Designate button1 as the default button.
this.defaultButton = button1;
}
}
“`
In this example, the button1 button is designated as the default button. When the user presses Enter, the button1 button will be automatically selected.