Strange focus behaviour

M

martin_link75

I have a windows application with a main form with MDI children.

Once in a while, not all the time, when a user hits return in a
RichTextBox in (which reside in a tabcontrol in the MDI child form) the
click event is triggered for a button in the same form. This is very
strange and is upsetting my customers.

If anyone experienced anything similar I would be very excited to hear
about it.

Any help would be greatly appreciated!

Sincerely
Martin
 
D

Dmytro Lapshyn [MVP]

Hi!

I recall that for a usual, plain-text TextBox, there was a setting named
something like "Wants Return". This setting determined how the textbox
handled the Enter key - whether it processed the Enter keystroke, or allowed
the keystroke to "bubble up" to the parent window. The same seems to be true
for the RichTextBox control, however, I can't find a managed code-way to
change this setting. Hence, lookup the MSDN docs on the EM_SETOPTIONS
message and the ECO_WANTRETURN flag (the same as WS_WANTRETURN).

If you have no experience in using Windows API from .NET, consider the
following website:

http://www.pinvoke.net

and the "microsoft.public.dotnet.framework.interop" newsgroup.
 
G

Guest

Check your forms AcceptButton property. If this is set, the button indicated
will be clicked in response to the ENTER key.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top