Hi,
C#. .Net 4.0
-------------
I've difficulties focusing a form. This is the scenario :
MDI application, Child forms are shown tabbed, like Firefox or IE8 tabs.
From one MDIchild form (MDIchild1) I open a dialog form (dialog1), from dialog1 I call a helper method (in Helper library) to create and show an MDIchild
form (MDIchild2), then close dialog1.
Everything is OK, except that the keyboard input goes to MDIchild1, though MDIchild2 is the one that has the focus.
And I want the keyboard input goes to MDIchild2.
NB. The MDiContainer form shows that MDIchild2 is the active child form.
Loading
Doha MsgPosted Dec 5, 2010, 3:28 AM
I use DevExpress XtraTabbedMdiManager to manage Child Tabs on my MainForm.
I've tried a simpler scenarion; but still I have the same problem, here is the scenarion:
From MainForm (MdiContainer) I click a button to show a Dialog Form (an Entry Form with Save, Cancel, Print options) if I choose Print option, from Dialog Form I create and show an MdiChildForm, this one shows tabbed correctly, the dialog closes; but the focus returns to the button on the MainForm.
Here is the method called by the button_Click on the MainForm:
[CODE]
private void LaunchVoucherNew(object sender, EventArgs e)
{
// creates and shows the Dialog Form
WinHelper.LaunchModalForm(typeof(VoucherEditForm), new VoucherEntity(), GeneralHelper.OperationType.Insert, this);
if (_voucherIdToPrint > 0)
{
_voucherIdToPrint = 0;
Form reporter = WinHelper.GetChildForm(typeof (Reporter));
if (reporter != null)
{
// The User has choosen the print options, which created and displayed the tabbed MdiChild
reporter.Focus();
// on the Debug mode right here, the next command line : ActiveMdiChild>
// shows : reporter.
// But the button on the MainForm actually has the focus
}
}
}
[/CODE]
The only way it works, but raising an exception is when I use the followin code in the creation of the MdiChild:
[CODE]
childForm.Owner = mdiParent;
childForm.MdiParent = mdiParent;
[/CODE]
The exception message is :
"Only top-level controls can have an owner. Parameter name: value".
The following code doesn't raine an exception; but doesn't also solve my focus problem :
[CODE]
childForm.MdiParent = mdiParent;
childForm.Owner = mdiParent;
[/CODE]
Kumar AGPosted Dec 1, 2010, 11:51 AM
In MDIForm1 code after displaying dialog form shift the focus to MDIForm2 if it's a tab control activate MDIForm2 tab. To do this dialog form should return reference of the MDIForm2 to MDIForm1.
Jean PaulPosted Dec 1, 2010, 11:14 AM