How to tell when control loses focus

J

JezB

I have a user control that I want to display slightly differently if it has
input focus. Trouble is, I can't see any event available (like FocusChanged)
to tell it when focus is gained and then lost again (upon which I want to
force repainting).

The same is true for any focusable Control (if I wanted to take any
particular action when it loses focus). What can I do ?
 
H

Herfried K. Wagner [MVP]

JezB said:
I have a user control that I want to display slightly differently if it has
input focus. Trouble is, I can't see any event available (like
FocusChanged) to tell it when focus is gained and then lost again (upon
which I want to force repainting).

Check out the controls' 'Enter', 'Leave', 'GotFocus', and 'LostFocus'
events.
 
H

Herfried K. Wagner [MVP]

JezB said:
What's the difference between Enter/Leave and GotFocus/LostFocus ?

Take a look at the documentation of 'LostFocus', for example, which contains
an overview of the order in which the events fire.
 

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