Setting focus to an MDI child not working

  • Thread starter Thread starter Mystery Man
  • Start date Start date
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.
 
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.
 
Back
Top