سؤال

Its Simple Repeated Question:

How set shortcut for buttons (ButtonBase-Element) without Command Binding?

I test AccessKeyManager, but I want to set Shorcuts with Modifier.
and Ppossible to do this with Code?

For example:

F1 .. F12
Ctrl + a .. z
Ctrl + F1 .. F12

هل كانت مفيدة؟

المحلول

This could give you a general idea on how you would go about things

    Keys lastkey = Keys.None;
    Button b = new Button();
    private void KeyPress(object sender, KeyEventArgs e)
    {
        if (lastkey == Keys.Control)
        {
            //Do some stuff
            b.PerformClick();
        }
        if (e.KeyCode == Keys.Control)
            lastkey = Keys.Control;
        else
            lastkey = e.KeyCode;
    }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top