Detecting when a datagrid control loses focus

G

Greg

The LostFocus event of datagrids is fired when the focus is added to a
cell. How do you go about detecting it when the control as a whole has
lost focus to another control?

Slightly confused by this!

Greg.
 
G

Guest

Greg,

I think you want the 'Leave' event for the DataGrid. That should fire when
the control itself is no longer the active control

WhiteWizard (aka Gandalf)
MCSD.NET, MCAD, MCT
 
G

Greg

Thanks for that. I've tried it, but this is only fired when the focus
is lost to another control, not the form. I need to know when the main
form receives focus, as well as any controls. However, due to
architectural constraints, I can't add any code to the main form - so
the coding has to be done within my derived datagrid.

Getting a reference to the main form and adding feedback for gotfocus
doesnt work either!

Thanks again.

Greg.
 
G

Guest

Greg,

I'm pretty certain that the main Form cannot get focus as long as there are
controls that can get the focus. However, you can use the "Activated" event
to know when the form has been entered/reentered after you leave it. That
might be what you need. This has changed in .NET as it gets fired more often
now. Basically it gets fired whenever you go away from the form and come
back to it, either from inside or from outside the application.

HTH
WhiteWizare (aka Gandalf)
MCSD.NET, MCAD, MCT
 

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