Pressing [ENTER] in a textbox

  • Thread starter Thread starter Paul Steele
  • Start date Start date
P

Paul Steele

Hi,

I've got a number of textbox's on a windows form in VC++ .NET.
I've got it so that when the user presses [ENTER] whilst in a textbox then
it goes to the next tabstop. This works fine however Windows play the ding
sound as if a invalid key has been pressed. Is there a way to stop this
happening.

Thanks in advance

Paul.
 
Hi,

You need to add a handler to the KeyPress event to 'handle' the event caused
by an Enter keypress (as in the following, shamelessly pinched from another
post today - piece of cake to convert it to C++).

Steve

private void textBox2_KeyPress(object sender,
System.Windows.Forms.KeyPressEventArgs e) {
if (e.KeyChar == 'r') e.Handled = true; // You can also test
against char(13)
}
 
Back
Top