Hi,

I want to assign a f2 key for the save button in my c# application,

is it possible ?

if not any other ways where i can assign short cut key for the buttons ?

any one can help me

Thanks in Advance ..

Recommended Answers

All 3 Replies

You need to bind the method to the form's KeyUp method available in the properties. I don't think it can be done using KeyPress instead. The following should work.

Assuming your using a WinForm of course..

private void Form1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F2)
            {
                //Enter code to save here
                MessageBox.Show("F2");
            }
        }

Thats not what he asked for.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.