Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change shortcut keys dynamically in form application?

I have a project in Windows form application. I want to implement dynamically shortcut keys in this application. User can change their shortcut keys as per requirement. How can I implement this dynamically shortcut keys?

like image 391
Animesh Ghosh Avatar asked Nov 03 '22 18:11

Animesh Ghosh


1 Answers

Here is something that might help, I know it isn't the best way to do but I can't do any better.

string ii = "";

    protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
    {
        if (keyData == (Keys.Control | Keys.C) && ii == "C")
        {
            MessageBox.Show("Your shortcut key is: C!!");
        }
        return base.ProcessCmdKey(ref msg, keyData);
    }

    private void comboBox1_TextChanged(object sender, EventArgs e)
    {
        ii = comboBox1.Text;
    }

Your comboBox1 is the ComboBox That contains your shortcut key options.

That might help some, you will have to add a bunch of if statements. Hope this helps!!

like image 86
Dozer789 Avatar answered Nov 08 '22 03:11

Dozer789