how to set the short cut key in VB.net (eg. Ctrl + O = Open file)

i am fresh in VB.net..so i got one quesiton here and need to be solve quickly.
how to set the button short cut key...for eg if i want to open a file, normally the short cut key is ctrl + O, i had add a edit button, but dunno how to set the short cut key for edit as Ctrl + E...hope can get answer here..


Answer this question

how to set the short cut key in VB.net (eg. Ctrl + O = Open file)

  • Vivek2

    using the Short Cut property of the Menu item,

    click on the menu item that you want to put a short cut and goto the property window search for ShortCut you can select it from dropdownlist.

    i hope you got it

  • Dudeman

    Hi,

    My suggestion is to trap the Ctrl+O from the form's keypress event. Here's a sample code:



           // don't forget to set your Form's KeyPreview property to true...
            private void Form1_KeyDown(object sender, KeyEventArgs e) {
                if (e.Control && e.KeyCode == Keys.O) {
                    MessageBox.Show("Testing");
                }
            }

     




    cheers,

    Paul June A. Domag


  • mamrg

    I am not sure about how to set Ctrl + O short cut key(not sure even you could do it), but i know how to set the Alt + O as a short cut key, see below:

    set the text property of the button to &Open (put the & in front of the key that you want)

    e.g.
    Button1.Text = "&Open Me"; //short cut key is Alt + O
    Button1.Text = "Click to &Edit"; //short cut key is Alt + E 

    hope it helps,

    Ivan Wong


  • nielsvanvliet

    sorry, i cant found the short cut field, there is no such a field exist..i am using microsoft visual studion .net 2003. do you have any other idea..hope for ur answer soon..thanks

  • how to set the short cut key in VB.net (eg. Ctrl + O = Open file)