Live Chat Icon For mobile
Live Chat Icon

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

Platform: WinForms| Category: 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}');
       
[VB.NET]
	If e.KeyCode = Keys.Enter Then
		SendKeys.Send('{TAB}')
	EndIf

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.