Form Lost Focus

J

Jesse

I have searched and searched, with no luck.

I have a Form that has several event listeners in it (Keypresses, speech
recognition, afew others). When I click a component in the form (such as a
button), the form itself loses focus.

How can I get it back? I have tried this.Focus() from w/in the form in a
timer with no luck as well as several other things.

Thanks!
 
M

Morten Wennevik [C# MVP]

Hi Jesse,

I'm guessing you have some code that is causing the form to lose focus.
This code may well also preventing you from resetting it. Review your code
to see if there is any code that may do so, possibly with assistance of the
LostFocus event to determine when this happens.
 
T

Tantr Mantr

Do you have anything in the Form Activate event? Try disabling all the form
events.

Cheers!
 
B

Ben Voigt [C++ MVP]

Jesse said:
I have searched and searched, with no luck.

I have a Form that has several event listeners in it (Keypresses,
speech recognition, afew others). When I click a component in the
form (such as a button), the form itself loses focus.

How can I get it back? I have tried this.Focus() from w/in the form
in a timer with no luck as well as several other things.

Instead of trying to make the Form regain focus, make the event handlers
work no matter what has focus.

Try this:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.application.addmessagefilter.aspx
 

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