Accept a RETURN on a TextBox, to act as a TAB

  • Thread starter Thread starter JezB
  • Start date Start date
J

JezB

I simply want the RETURN key, when hit on a TextBox control, to act like a
TAB key, ie. move focus to the next control and fire the Validate event on
this control. Instead in just beeps at me and doesn't move.
 
This works, thanks very much.

However, the BEEP is still issued which is kind of annoying. The control is
a normal TextBox with MultiLine = False (setting it to True does prevent the
beep but then the return key is entered into the TextBox too!). The
AcceptsReturn property doesn't seem to have any effect.

Aha, before I posted I found the answer: set MultiLine = True and in
handling the return character set e.Handled = true too to prevent the return
character being inserted into the text:

private void filterText_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
this.ProcessTabKey(true);
e.Handled = true;
}
}
 
Back
Top