# Using Mnemonics in Toolbar

## Content

**Mnemonics**, also known as access keys, are keyboard shortcuts that improve accessibility and navigation in desktop applications.
In a standard WinForms application, an access key is typically specified by placing an ampersand (&) before a character in a control's **Text** property. When the **Alt** key is pressed in combination with that character, the associated control is activated or focused.
For example:

```auto
#
myButton.Text = "&Save";
```

This makes **Alt + S** the shortcut for activating the button.

### **Enabling Mnemonics in C1Toolbar**

The C1Toolbar control supports mnemonics through the UseMnemonic property.

```auto
public bool UseMnemonic { get; set; }
```

#### **To activate mnemonics for commands within C1Toolbar**

1. Set the **UseMnemonic** property to True.

```auto
namespace MnemonicsToolbar
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            label1 = new Label
            {
                AutoSize = true,
                Location = new Point(374, 406),
                Margin = new Padding(4, 0, 4, 0),
            };

            var c1ToolBar1 = new C1.Win.Command.C1ToolBar
            {
                UseMnemonic = true,
            };
```

2. Define mnemonics in C1Command by inserting an ampersand (&) before the preferred character in the command’s **Text** property. This allows in triggering the command by pressing **Alt+ [Mnemonic key].**

```auto
var undoCommand = new C1.Win.Command.C1Command
            {
                Text = "&Undo",
            };
            undoCommand.Click += Undo_Clicked;

            var undoCommandLink = new C1.Win.Command.C1CommandLink
            {
                Command = undoCommand,
            };

            var redoCommand = new C1.Win.Command.C1Command
            {
                Text = "&Redo",
            };
            redoCommand.Click += Redo_Clicked;

            var redoCommandLink = new C1.Win.Command.C1CommandLink
            {
                Command = redoCommand,
            };

            c1ToolBar1.CommandLinks.AddRange([undoCommandLink, redoCommandLink]);

            this.Controls.Add(c1ToolBar1);
            this.Controls.Add(label1);
        }

        private void C1CommandHolder1_CommandClick(object sender, C1.Win.Command.CommandClickEventArgs e)
        {
            label1.Text = e.Command.Text + " clicked via CommandHolder";
        }

        private void Undo_Clicked(object sender, C1.Win.Command.ClickEventArgs e)
        {
            label1.Text = "Undo clicked";
        }

        private void Redo_Clicked(object sender, C1.Win.Command.ClickEventArgs e)
        {
            label1.Text = "Redo clicked";
        }

        private Label label1;
    }
}
```

By setting the **UseMnemonic** property to True, users can activate these commands using access keys. In this code, Alt + U activates the Undo command and Alt + R activates the Redo command. Each command is associated with an event handler that updates a label on the form to indicate which action was triggered.