I have a few TextBox on the WinForm. I would like the focus to move to the next control when Enter key is pressed? Whenever a textbox gains control, it will also select the text, so that any editing will replace the current one.
What is the best way to do this?
Tab as Enter: create a user control which inherits textbox, override the
KeyPressmethod. If the user presses enter you can either callSendKeys.Send("{TAB}")orSystem.Windows.Forms.Control.SelectNextControl(). Note you can achieve the same using theKeyPressevent.Focus Entire text: Again, via override or events, target the
GotFocusevent and then callTextBox.Selectmethod.