Bug with TabbedMDI?

Hi,

I think there is a problem with TabbedMDIManager. Attached is a modified version of TabbedMDI sample app shipped with Syncfusion Essential Suite 4.2.0.60.

In this modified version, i added
tabbedMDIManager.ShowCloseButton = true;
to the MainForm constructor. I also added a Document1_Closing event handler in Document1.cs.

What happens now is that if I try to close a MDI child document (say document4) by clicking on the X close button next to the document title, and then choose Cancel on the dialog box, the tabbedMDIManager will activate another document (say document3). But I will expect that document4 should still be activated if i choose to cancel closing the form.

Can you provide me with a workaround, 'cause my users are complaining about this wired behavior.

Thanks very much,

Frank

TabbedMDI5.zip

3 Replies

GS Gopalakrishnan S Syncfusion Team January 19, 2007 01:42 AM UTC

Hi Frank,

Thanks for choosing Syncfusion products.

I have used the two static variables ( activeChild,flag) in the MainForm.cs for handling activeMdiChild. Please change the code in MdiChildActivated and Document_Closing methods as shown below in order to get this work.

Here is the modified code snippet:

In MainForm.cs ,

Public static Document1 activeChild;
public static Boolean flag = true;

protected void MDIChildActivated(object sender, System.EventArgs e)
{
if (flag == false)
{
this.ActivateMdiChild(activeChild);
flag = true;
}

if (this.ActiveMdiChild == null)
{
statusBar1.Text = "";
}
else
{
statusBar1.Text = this.ActiveMdiChild.Text;
}

}

In Document1.cs

private void Document1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{

DialogResult rst = MessageBox.Show("Do you want to close this window?", "TabbedMDI",
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);
if (rst == DialogResult.No)
{
e.Cancel = true;
MainForm.activeChild = this;
MainForm.flag = false;
return;
}
else if (rst == DialogResult.Cancel)
{
e.Cancel = true;
MainForm.activeChild = this;
MainForm.flag = false;
return;
}
else
MainForm.flag = true;
}


Please refer the attachments.

TabbedMDI.zip

Please let me know if this works.

Regards,
S.Gopal.


AD Administrator Syncfusion Team January 19, 2007 03:39 PM UTC

Hi Gopal,
Thanks for your reply. I couldn't run your app because I'm developing with VS2003. But i tried your method in my application, and unforturnately it did NOT work. Do you have any other suggestions?
Thanks,
Frank


GS Gopalakrishnan S Syncfusion Team January 19, 2007 07:51 PM UTC

Hi Frank,

Sorry for the inconvenience. For now, you could use the following workaround :

1. Handle the TabbedMDIManager's TabControlAdded event and get the TabControlAdv associated with it

manager.TabControlAdded += new TabbedMDITabControlEventHandler(manager_TabControlAdded);

private void manager_TabControlAdded(object sender, TabbedMDITabControlEventArgs e)
{
e.Tabcontrol.SelectedIndexChanging +=new SelectedIndexChangingEventHandler(tabcontrol_SelectedIndexChanging);
}


2. Handle the SelectedIndexChanging event of this TabControlAdv and cancel the new tab selection when the click the Cancel or No button in the dialogox.

private void tabcontrol_SelectedIndexChanging(object sender, SelectedIndexChangingEventArgs e)
{
if(flag==false)
{
e.Cancel=true;
flag=true;
}
}


3) Set the flag variable in the Document_ closing method.
if (rst == DialogResult.No)
{
e.Cancel = true;
MainForm.flag = false;
return;
}

TabbedMDI_Sample.zip

Please let me know if this works.

Thanks,
S.Gopal

Loader.
Up arrow icon