views:

767

answers:

1

Sorry for the long title, but I couldn't think of another way to put it.

I have this:

    private void textBoxToSubmit_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Enter)
        {
            buttonSubmit_Click((object)sender, (EventArgs)e);
        }
    }

... in order to make pressing enter in the text box trigger the "submit" button. However, this also prevents shortcuts from going through. (not quite sure what it has to do with that, maybe only multi-key combos?)

ShortcutsEnabled is set to true.

Thanks in advance!

Jonathan

A: 

Can you not use AcceptButton in for the Forms Properties Window? This sets the default behaviour for the "Enter" key press, but you are still able to use other shortcuts.

Rob Cooper
I see! Thanks for clarifying this. I'm obviously new to C#, so simple things like this confuse me.Thanks!
Jonathan Chan
No problem - happy to help :)
Rob Cooper