Event handler problem !

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
 
O

Olivier DALET

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 ?
 

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