Call a method on pressing enter after writing in a textbox

  • Thread starter Thread starter ShoCkwave
  • Start date Start date
S

ShoCkwave

I have a textbox. If I write something in it and then press enter I
want a specific method to be executed.

How can I add this event to textBox? Thanks.
 
Use the KeyPress event.

private void textBox1_KeyPress(object sender,
System.Windows.Forms.KeyPressEventArgs e)
{
if (Convert.ToInt32(e.KeyChar) == (int)Keys.Enter)
{
// Call method.
}
}

--
Tim Wilson
..Net Compact Framework MVP

ShoCkwave said:
I have a textbox. If I write something in it and then press enter I
want a specific method to be executed.

How can I add this event to textBox? Thanks.
 
Back
Top