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. Image for the cookie policy date

Changing form.MdiParent with TabbedMDIManager causes OnLoad to be called multiple times

I'm using multiple mdi parent forms each with their own TabbedMDIManager instance. I want to be able allow the user to open the currently active tab (mdi child) in a new parent form ( a "Open in New Window" option).

So when the user clicks on this option, they expect to see the control move from the current form to a new one. The control itself is recreated - just has it's MdiParent changed.

I've implemented this with the following code:

private void AttachForm(MainForm mdiParent, DockedForm mdiForm)
{
// NOTE: set the MDI parent to null first otherwise the form does not seem
// to attach properly to the new parent
mdiForm.MdiParent = null;
mdiForm.MdiParent = mdiParent;
mdiForm.Show();
}

Firstly, I found I had to clear the MdiParent before setting it to a new form. Otherwise, the child would never appear in the new form.

Secondly and more importantly, by changing the MdiParent property it causes the OnLoad and OnCreateControl() methods to be called each time.

OnLoad() should only be called once when the control is created - all I'm doing here is changing the MDI parent. A small test app without the TabbedMDIManager does not cause the OnLoad method to be called multiple times.

I've looked in the TabbedMDIManager source code but can't see why this is happening. Can you please advise how I can implement this functionality without the same control instance being initalised repeatedly.

Jas.

3 Replies

JS James Sandys-Lumsdaine April 16, 2007 09:14 AM UTC


>The control itself is recreated -

Sorry - this should read "The control itself is NOT recreated - ...".


JS James Sandys-Lumsdaine April 19, 2007 04:46 PM UTC

Any help on this? Thx.


GR Golda Rebecal Syncfusion Team April 20, 2007 02:15 PM UTC

Hi jas_sl,

Sorry for the delay in responding.

1) When MDI parent of a tabbed MDI child form is changed, the MDIParent have to be cleared before setting the new parent

I could see this issue only when the child is transferred to a MDI parent without having any child. I will forward this issue to the development team and they will get back to you. In the attached sample, I have changed the MDI parent without clearing it and the child is transferred to the new form that is already having a mdi child

2) OnLoad() method of the MDI child is called when the MDI parent of the child form is changed.

I am afraid that I am not able to reproduce the issue with the attached sample. Could you please modify the sample so that the issue could be reproduced? This will help us to resolve the issue soon.

Thanks for using Syncfusion products.

http://websamples.syncfusion.com/samples/tools.Windows/F59506/main.htm

Best regards,
Golda

Loader.
Live Chat Icon For mobile
Up arrow icon