Event handler problem !

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How to prevent that the Button_Click event comes if one pressed Enter on TextBox which has a valid event handler

Thanks for your response
 
I'm not sure I really get your problem.
Some possible clues:

if your button is the accept button of your form. Pressing enter is similar
to clocking on it. Something like that:

private void InitializeComponent()
{
...
this.AcceptButton = this.button1; // this refers to the current
form
...
}

If you do want your button to accept the form, you should consider to set
these two Textbox properties to true:

this.textBox1.AcceptsReturn = true;
this.textBox1.Multiline = true;

thus, when pressing enter and the textbox has focus, it will generate a
carriage return in the textbox.

Olivier DALET
-------------------

REIVILONOSSALG said:
How to prevent that the Button_Click event comes if one pressed Enter on
TextBox which has a valid event handler ?
 
Back
Top