ComponentOne Windows 7 Control Pack for WinForms
Setting the Access Key
Windows 7 Control Pack for WinForms Task-Based Help > C1TaskDialog Task-Based Help > Setting the Access Key

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 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 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 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:

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.UseCommandLinks = False
    Dim C1CustomButton1 As New C1.Win.C1Win7Pack.C1CustomButton
    C1CustomButton1.Text = "&Access Key Example"
    C1TaskDialog1.CustomButtons.Add(C1CustomButton1)
End Sub

To write code in C#

C#
Copy Code
public Form1()
{
    InitializeComponent();
    c1TaskDialog1.UseCommandLinks = false;
    C1CustomButton c1CustomButton1 = new C1CustomButton();
    c1CustomButton1.Text = "&Access Key Example";
    c1TaskDialog1.CustomButtons.Add(c1CustomButton1);
}

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.