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

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.
 
J

JezB

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;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top