# Setting the Access Key

## Content



An access key is an underlined character in the text of a menu, menu item, or the label of a control such as a button. With an access key, the user can "click" a button by pressing the ALT key in combination with the predefined access key. For more information, see the [Access Keys](/componentone/docs/win/online-winpack/workingwithwindows7c/workingwithc1taskdia/accesskeys) topic. In this topic, you'll add a custom button with an access key to an existing **C1TaskDialog** control.

### In the Tasks Menu

Complete the following steps to add a command link button with an access key to an existing **C1TaskDialog** control:

1.  On the Form in Design view, click once on the **C1TaskDialog** component to select it.
2.  Click the control's smart tag to open the **C1TaskDialog Tasks** menu. For more information about the menu, see the [C1TaskDialog Tasks Menu](/componentone/docs/win/online-winpack/designtimesupport/windows7controlpackf3/c1taskdialogtasksmen) topic.
3.  In the **C1TaskDialog Tasks** menu, uncheck the **Use Command Links** check box.
4.  In the **C1TaskDialog Tasks** menu, click the **Add Custom Buttons** item. The **C1TaskDialog.CustomButtons Collection Editor** will open.
5.  In the **CustomButtons Collection Editor**, click the **Add** button to add a new **CustomButton**.
6.  Set the button's **Text** property in the Properties pane to "&Access Key Example". The ampersand indicates that the letter after the ampersand should be used as the access key.
7.  Click OK to close the **CustomButtons Collection Editor**.

### In the Properties Window

Complete the following steps to add a command link button with an access key to an existing **C1TaskDialog** control:

1.  On the Form in Design view, click once on the **C1TaskDialog** component to select it.
2.  Navigate to the Properties window and set the [UseCommandLinks](/componentone/api/win/online-winpack/dotnet-framework-api/C1.Win.C1Win7Pack.4.8/C1.Win.C1Win7Pack.C1TaskDialog.UseCommandLinks.html) property is set to **False**.
3.  In the Properties window, click the ellipses button next to the **CustomButtons** item. Alternatively, if the **Commands** area beneath the Properties window is displayed, you can select the **Edit Custom Buttons** item. The **C1TaskDialog.CustomButtons Collection Editor** will open.
4.  In the **CustomButtons Collection Editor**, click the **Add** button to add a new **CustomButton**.
5.  Set the button's **Text** property in the Properties pane to "&Access Key Example". The ampersand indicates that the letter after the ampersand should be used as the access key.
6.  Click **OK** to close the **CustomButtons Collection Editor**.

### In Code

The following code adds a command link button with an access key to an existing **C1TaskDialog** control:

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.UseCommandLinks = False
    Dim C1CustomButton1 As New C1.Win.C1Win7Pack.C1CustomButton
    C1CustomButton1.Text = "&Access Key Example"
    C1TaskDialog1.CustomButtons.Add(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.UseCommandLinks = false;
    C1CustomButton c1CustomButton1 = new C1CustomButton();
    c1CustomButton1.Text = "&Access Key Example";
    c1TaskDialog1.CustomButtons.Add(c1CustomButton1);
}
```

DOC-DETAILS-TAG-CLOSE

### When You've Accomplished

In this topic, you've added a custom button with an access key to an existing **C1TaskDialog** control. Run your application, and when the **C1TaskDialog** dialog box is open press the ALT + A keys to "click" the button.