470,602 Members | 1,504 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,602 developers. It's quick & easy.

Detecting when a datagrid control loses focus

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.

Apr 18 '06 #1
3 5948
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
"Greg" wrote:
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.

Apr 18 '06 #2
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.

Apr 18 '06 #3
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
"Greg" wrote:
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.

Apr 18 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by epigram | last post: by
11 posts views Thread by =?Utf-8?B?RWl0YW4=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.