C#:Handling Enter key press event for textbox.

If you want to do something when focus is on textbox and and user press ‘Enter’ key, do the following way:

private void txt1_KeyPress(object sender, KeyPressEventArgs e)</code>
 if (e.KeyChar == (char)Keys.Enter)
    //do something

where txt1 is textbox

Published in: on August 5, 2009 at 3:31 pm  Leave a Comment  
Tags: , , ,

The URI to TrackBack this entry is: https://indiandeve.wordpress.com/2009/08/05/chandling-enter-key-press-event-for-textbox/trackback/

RSS feed for comments on this post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: