Bug w/ button having focus while in textbox

G

Guest

There seems to be a bug where if you're in a textbox, a button can still have focus and prevent you from using the "enter" key in the multi-line textbox. This happens when you have a button and a textbox in a child form, go to another child and return back to the initial child. Here's how to re-create the problem:

1. Create a child form with a button and a MULTILINE textbox.
2. In the MDI parent form, open two of those child forms (you could do it in the OnLoad event)
3. Run the program. Two child forms should show. Let's call the child that's on top "child 1" and the other "child 2"
4. "child 1" is currently on top. Now, click on "child 2" and click back on "child 1".
5. Click on the textbox on "child 1" and hit return ("ENTER"). You will NOT be able to go down to the next line.

It seems that upon re-activating "child 1", the form gives the button the focus again, but does not "release" the focus even when you put the cursor in the textbox.

So, even though you click on the text box & put the cursor there, hitting ENTER still makes the form fire the Click event on the button.

I have not found anything like this in the KB. If you have any workaround or know the solution please let us know.

Thanks!

jgc
 
Y

Yuriy Solodkyy

I think this behaviour is by design. For considers last activated buttont
as default form button. According to "TextBox.AcceptsReturn Property" help
topic you must set this property to "true", to ensure RETURN key is always
handled by the textbox control.

--
Yuriy

jgc said:
There seems to be a bug where if you're in a textbox, a button can still
have focus and prevent you from using the "enter" key in the multi-line
textbox. This happens when you have a button and a textbox in a child form,
go to another child and return back to the initial child. Here's how to
re-create the problem:
1. Create a child form with a button and a MULTILINE textbox.
2. In the MDI parent form, open two of those child forms (you could do it in the OnLoad event)
3. Run the program. Two child forms should show. Let's call the child
that's on top "child 1" and the other "child 2"
4. "child 1" is currently on top. Now, click on "child 2" and click back on "child 1".
5. Click on the textbox on "child 1" and hit return ("ENTER"). You will
NOT be able to go down to the next line.
It seems that upon re-activating "child 1", the form gives the button the
focus again, but does not "release" the focus even when you put the cursor
in the textbox.
So, even though you click on the text box & put the cursor there, hitting
ENTER still makes the form fire the Click event on the button.
I have not found anything like this in the KB. If you have any workaround
or know the solution please let us know.
 

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