Focus on Control of Child's Form

K

khurram

Hi All,
I am working on a windows form application and we have an MDI form
with Toolbar on it. On click event of toolbar we are creating a specific
instance of a child form and showing it. Now on the child form we want to
set the focus on the first field and for that purpose we set the tab order
as well as calling the control.Focus method at the end of form constructor
method.
For some reason the child forms first field does not get the focus. On
inspection we find out that the Main MDI form is getting the focus and then
the focus moves to the child form but the first field does not get the
focus. I think it has something to do with MDI behaviour. Does anybody have
any idea ?
FYI, I am using .Net infragistics windows control (Tool bar etc.) and
running Visual Studio 2003 on Windows XP.Any help would be greatly
appreciated.

Thanks,
Khurram
 
G

Graham McKechnie

Khurrm,
On inspection we find out that the Main MDI form is getting the focus and
then
the focus moves to the child form but the first field does not get the
focus. I think it has something to do with MDI behaviour. Does anybody have
any idea ?
You didn't mention which field eventually got focus. However I believe you
are probably calling the control.focus too early if you do it in the ctor.
Try the form load event instead. As a last resort I'd try the Form.GotFocus
event if Form.Load wont do it for you. I've not done much MDI with .Net, but
I doubt its got anything to do with MDI. Have you got any other stuff going
on in the ctor that is maybe firing events you don't want?

Graham
 

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