.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Windows Form Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Move To Next Control using Enter Instead of Tab

Posted By:Hefin Dsouza       Posted Date: August 12, 2009    Points: 10    Category: Windows Form Controls    URL: http://www.dotnetspark.com  
 

This Code Will make your application move to the next control by pressing enter.

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress, TextBox2.KeyPress, TextBox3.KeyPress, TextBox4.KeyPress
If Keys.Enter Then
SelectNextControl(sender, True, False, False, True)
End If
End Sub

Note that you can add the same event to many controls by using ",".
In This Example I have coded on TextBox1 But the event is fired by all the textboxes because i have added these codes

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress, TextBox2.KeyPress, TextBox3.KeyPress, TextBox4.KeyPress



NOTE : That you have to set TabIndex in order.

Regards Hefin Dsouza


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend