# Setting the Default Button

## Content



To set the default button you can use the [SetDefaultButton](/componentone/api/win/online-winpack/dotnet-framework-api/C1.Win.C1Win7Pack.4.8/C1.Win.C1Win7Pack.C1TaskDialog.SetDefaultButton.html) method to the name of the button. The default button indicates which button is clicked when the **C1TaskDialog** control has focus and the user presses the ENTER key.

### In the Properties Window

Complete the following steps to set the default button to an existing button:

1.  On the Form in Design view, click once on the **C1TaskDialog** component to select it.
2.  Navigate to the Properties window and locate the **DefaultButton** item.
3.  Click the drop-down area next to the **DefaultButton** item and select the button you want to be set to the default button.

### In Code

The following code sets the default button:

DOC-DETAILS-TAG-OPEN

DOC-SUMMARY-TAG-OPEN

To write code in Visual Basic

DOC-SUMMARY-TAG-CLOSE

```vbnet
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    C1TaskDialog1.SetDefaultButton(C1CustomButton1)
End Sub
```

DOC-DETAILS-TAG-CLOSE

DOC-DETAILS-TAG-OPEN

DOC-SUMMARY-TAG-OPEN

To write code in C#

DOC-SUMMARY-TAG-CLOSE

```csharp
public Form1()
{
    InitializeComponent();
    c1TaskDialog1.SetDefaultButton(c1CustomButton1);
}
```

DOC-DETAILS-TAG-CLOSE

### When You've Accomplished

In this topic, you've set the default button to an existing button. If you run the application, you'll see that the button you indicated is set as the default button – if you open the dialog box and press the ENTER key, the button will be selected.