I have a basic custom dialog box for use with various controls in a WinForms application. The dialog looks like:

For various reasons I do not want the user to have the ability to use the Enter key to select the ‘Yes’ option (buttonYes). Previously I did want this behaviour and I set the AcceptButton property of the Yes button (buttonYes) accordingly. I have scince removed this, setting buttonYes‘s AcceptButton property to ‘None’, but the form still fires the buttonYes.Click event when the Enter key is pressed. I have also tried to handle the KeyPress or KeyDown events but these are not being fired when the Enter key is used. This is basic and annoying, has anyone come across this and what can I do to implement the functionality I want?
To fix this, set the
TabStopproperty toFalseand use the code below:Or, if as you say, you are not able to break at KeyPressEvent you need to handle ProcessKeyPreview