Setting focus to an MDI child not working

M

Mystery Man

We have an MDI application that is not setting always setting focus to
the newly corrected MDI. It is creating the form and it is the topmost
but it does not have focus.

The code we are using to activate the MDI is something like the
following:

frmTest frm = new frmTest();
frm.MdiParent = this;
frm.Show();

I have tried calling frm.Activate() and Focus() but to no avail.
Creating a non-MDI works OK.


We are launching the MDI by double clicking on a DeveloperExpress
grid. However, if we use a context menu on the grid and go through
exactly the same handler code to open the form, then this works fine.

Therefore, I am not sure if it is a .NET problem, a DeveloperExpress
problem or what? I notice that in the newsgroup some other people were
having similar problems with focus on MDI child forms.
 
P

Prateek

Hi,

Seems like a DevExp problem because this does work fine in a normal
MDIParent-Child scenario.

However, make sure you are calling the Focus method of the Child Form after
its Show() method.

Another thing you may want to try is to set Focus to a control in the child
form. Suppose, the child form contains a textbox named TextBox1, then set
the following line after the call to the Show() method.
f.TextBox1.Focus();

Let me know if this was helpful.

-Prateek


We have an MDI application that is not setting always setting focus to
the newly corrected MDI. It is creating the form and it is the topmost
but it does not have focus.

The code we are using to activate the MDI is something like the
following:

frmTest frm = new frmTest();
frm.MdiParent = this;
frm.Show();

I have tried calling frm.Activate() and Focus() but to no avail.
Creating a non-MDI works OK.


We are launching the MDI by double clicking on a DeveloperExpress
grid. However, if we use a context menu on the grid and go through
exactly the same handler code to open the form, then this works fine.

Therefore, I am not sure if it is a .NET problem, a DeveloperExpress
problem or what? I notice that in the newsgroup some other people were
having similar problems with focus on MDI child forms.
 

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