We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Bug with TabbedMDI?

Thread ID:

Created:

Updated:

Platform:

Replies:

54881 Jan 18,2007 06:10 PM Jan 19,2007 02:51 PM Windows Forms 3
loading
Tags: Tools
Administrator [Syncfusion]
Asked On January 18, 2007 06:10 PM

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

Gopalakrishnan S [Syncfusion]
Replied On January 18, 2007 08:42 PM

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.

Administrator [Syncfusion]
Replied On January 19, 2007 10:39 AM

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

Gopalakrishnan S [Syncfusion]
Replied On January 19, 2007 02:51 PM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;