shortcut keys

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aaron

    #1

    shortcut keys

    How can I add a shortcut key to a button in a windows app.?
    for example
    i have a button called submit and right now the only way to execute
    its function is to left click the button. I would like to add a
    shortcut key that correspond to this action. ctrl+s


    quesitons no.2
    how come when i hit the enter key in a windows control text input
    field it doesn't submit? it will only submit if i click the submit
    button. is there a command i missed? (I hope this makes sense)

    thanks

    Kuya
  • Deming He

    #2
    Re: shortcut keys

    Aaron <kuya789@yahoo. com> wrote in message
    news:b4828959.0 311281046.4a131 20b@posting.goo gle.com...[color=blue]
    > How can I add a shortcut key to a button in a windows app.?
    > for example
    > i have a button called submit and right now the only way to execute
    > its function is to left click the button. I would like to add a
    > shortcut key that correspond to this action. ctrl+s
    >
    >[/color]

    Add an event handler to key-pressing of the button, within your Form class:

    private void button1_KeyPres s(object sender,
    System.Windows. Forms.KeyPressE ventArgs e)
    {
    /* If Esc key pressed, for example */
    if (e.KeyChar == (char) 27)
    {
    MessageBox.Show ("Esc pressed!!!");
    }
    }


    Comment

    Working...