Scope of Focus

J

JezB

In one Form if you move Focus (programatically or via user interaction) from
one control to another, the control you have moved FROM automatically loses
Focus and fires the Leave event.

What I want to do is always maintain a Focus within a specific container (a
Panel in my case). Within the Panel I want it to always keep one control in
Focus, even if I click the mouse in a control outside the container. Is this
possible via the standard Focus mechanism, or will I have to write my own
bespoke code ?
 
G

Guest

What I want to do is always maintain a Focus within a specific container (a
Panel in my case). Within the Panel I want it to always keep one control in
Focus, even if I click the mouse in a control outside the container.

Can you arrange for all the controls outside the container to be disabled?
If so, that should solve the problem.

On the other hand, maybe you have a few controls outside the container that
you want to be enabled, and when they have done their thing, you want focus
to return to where it came from. For example, some buttons that when
clicked, you want to give focus back to where it came from. I do this in a
form by handling the Enter event for for the controls I want to return focus
to (your container controls). The last thing button clicks do is call Focus
on the most recently entered control.
 

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