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.
 

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

Back
Top