Button behaviour

  • Thread starter Thread starter Alan T
  • Start date Start date
A

Alan T

Can I configure a button so that when I press "Enter" key in a text box to
trigger the button onclick event?
 
Change the containing form's .AcceptButton to the button; this should
then work (for single line boxes).

If this isn't possible (e.g. a UserControl or a multi-line box) you may
need to handle keypress events instead.

Marc
 
Hello Alan,

In the button Key_Down handler check that KeyEventArgs.KeyCode == Keys.Enter
and call onclick handler


AT> Can I configure a button so that when I press "Enter" key in a text
AT> box to trigger the button onclick event?
AT>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
Back
Top