ComponentOne Windows 7 Control Pack for WinForms
Windows 7 Control Pack for WinForms Task-Based Help / C1TaskDialog Task-Based Help / Setting the Default Button
In This Topic
    Setting the Default Button
    In This Topic

    To set the default button you can use the SetDefaultButton 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:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        C1TaskDialog1.SetDefaultButton(C1CustomButton1)
    End Sub
    

    To write code in C#

    C#
    Copy Code
    public Form1()
    {
        InitializeComponent();
        c1TaskDialog1.SetDefaultButton(c1CustomButton1);
    }
    

    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.