Microsoft Communities

Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

How do I make the focus move to the next control when the user presses the Enter key in a TextBox?

Add a handler for your TextBox's KeyDown event. (This assumes you set the AcceptsReturn property to False). Then in your KeyDown eventhandler, have code such as:

[C#]

if (e.KeyCode = Keys.Enter)
  SendKeys.Send("{TAB}");

[Visual Basic]

If e.KeyCode = Keys.Enter Then
  SendKeys.Send("{TAB}")
EndIf

Contributed from George Shepherd's Windows Forms FAQ



Page view counter