In the visual designer there is an option in the properties of the menu item that allows this.
The property is ShortcutKeys - the num pad keys are options in the drop down for this.
In the codebehind the designer generates:
this.myToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.NumPad0)));
So you could easily set this yourself from your code if you wanted.
One thing to note is that this only works when the Num Lock is on - I'm pretty sure it is not possible to assign two shortcut keys to the same menu item, so if you want this to work when Num Lock is off as well as on then you will need to handle key press events.
This SO post covers how you can do that. The code from the post is below, with the Insert specified (since this is the non Num Lock key to match NumPad0 from above.
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == (Keys.Control | Keys.Insert))
{
// Call your menu item handler here
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
System.Windows.Forms.MenuItem
. I have however been able to override the method as demonstrated in the post you linked. That works fine - though not exactly what I wanted :D Thanks !!! – (as above), the control is Triple Point Jan 07 '10 at 08:16