I have a .net WinForm dialog, which displays some TextBoxes (some of them are Multiline), a button marked as AcceptButton and one marked as CancelButton.
When you hit the return key, the onClick event of the AcceptButton is triggered and the dialog closes.
The matter is that the onClick event is triggered EVEN IF the user tries to insert a new paragraph in a multiline TextBox. The only way to prevent the close of the form is pressing CTRL + Return.
This is a manifestly a bug of the WinForm TextBox control.
For example a DataGridView correctly catches the Return-key and doesn’t passes it to the WinForm dialog.
Treid Select(), Focus(), overriding PreProcessMessage, ProcessKeyMessage (which strangely don’t even fire). No luck.
Me stupid!
There is a boolean property of the TextBox named AcceptReturn.
I think it should be autochecked by VS when checking Multiline.