This topic demonstrates how to use shortcut and mnemonic keys to access a menu by the keyboard instead of the mouse. You can apply shortcut and mnemonic keys to a menu item at design time or through code.
Within the event handler insert code to change the back color of the PictureBox to violet:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
If sender Is c1CommandMenu1 Then Me.pictureBox1.BackColor = Color.Violet End If |
To write code in C#
C# |
Copy Code
|
---|---|
if (sender == c1CommandMenu1) { this.pictureBox1.BackColor = Color.Violet; } |
Run the application and press the F6 key when the form appears. The picture box appears on the form.
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Me.C1CommandMenu1.Shortcut = System.Windows.Forms.Shortcut.F6 |
To write code in C#
C# |
Copy Code
|
---|---|
this.C1CommandMenu1.Shortcut = System.Windows.Forms.Shortcut.F6; |