I have a Windows Form, with a ListView and a TextBox placed right on top of it. Also there is a button named 'Submit' on the Form with AcceptButton set to true.
Now, my requirement is that, whenever I load the form and hit Enter, Submit button gets triggered, which is fine. But, when I select the TextBox and type something in it and then hit Enter, the focus should come to the ListView , but not the AcceptButton
How can I achieve this?
You can set the
AcceptButtonbased on the active control, or as a better option, handleProcessDialogKeyyourself. This is the method which contains the logic forAcceptButton.So you can override it, for example: