Customizing Run-Time Keyboard Menu Items

I need to provide a function for assigning keyboard shortcuts to any menu item or buttons at runtime by the user. I am using Visual Studio 2012. Please suggest a standard method for this.

UPDATE

Saving shortcuts to the configuration file is an option. I am looking for the best regarding

  • Display keyboard shortcuts and menu items
  • Some other commands that may or may not be shown on the menu will also be included.

I am looking for a standard way to continue non-code. Is saving to the configuration file the best way to consider if any key is changed by the user at runtime other than updating the configuration file. This will be a kind of custom setting.

+3
source share
1 answer
private void AssignKey(ToolStripMenuItem item, string keyName)
    {
        try
        {
            Keys key = (Keys)Enum.Parse(typeof(Keys), keyName);
            item.ShortcutKeys = key;
        }
        catch (ArgumentException)
        {
            MessageBox.Show("Unknown key " + keyName);
        }
    }

EDIT

No update available.

Anywho, just save the shortkeys in the "config" class, which has a Save method and saves it every time the software closes.

0
source

All Articles