How to use single key shortcut in MenuStrip in WinForms?

Viewed 405

I'm a beginner in c# /.NET and this is my first question. I didn't find similar questions.

I have a simple window game where keyboard is useless (similar to Minesweeper). I want to add a "P" shortcut in MenuStrip to "Pause" option.

I tried this in Form1.Designer.cs:

this.pauseToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.P;

but i get a error called System.ComponentModel.InvalidEnumArgumentException. ("Argument value "value" (80) is not the correct to Enum type "Keys". Parameter name: value")

I tried too change it in Solution Explorer -> Properties -> Different -> ShortcutKeys but VisualStudio blocks it and return value to None.

On the other hand i type this line:

this.newgameToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F2;

and it works perfect.

Is there any way to do this? btw sorry for my english if I wrote something wrong.

0 Answers
Related