This is a migrated thread and some comments may be shown as answers.

LoadFromXML MDI problems

1 Answer 57 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Graeme Lynch
Top achievements
Rank 1
Graeme Lynch asked on 02 Mar 2011, 03:31 PM
I have been using the RadDock control to manage my MDIs for me. This has been reasonably successful until I save a layout to reload later.

I am trying to reload the content using radDock1_DockWindowAdded()

                    if (e.DockWindow.Name.StartsWith("input1"))
                    {
                        input1 in1 = new input1();
                        in1.Text = e.DockWindow.Text;
                        in1.MdiParent = this;
                        ((HostWindow)e.DockWindow).LoadContent(in1);

This appears to work but I get an exception 

System.NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.WinControls.UI.Docking.RadDock.RegisterWindow(DockWindow dockWindow)
   at Telerik.WinControls.UI.Docking.RadDock.EnsureRegisteredWindow(DockWindow window, RadDockTransaction transaction)
   at Telerik.WinControls.UI.Docking.RadDock.EnsureTransaction(RadDockTransaction transaction)
   at Telerik.WinControls.UI.Docking.RadDock.CommitTransaction(RadDockTransaction transaction)
   at Telerik.WinControls.UI.Docking.RadDock.CommitTransactions()
   at Telerik.WinControls.UI.Docking.RadDock.EndTransactionBlock()
   at Telerik.WinControls.UI.Docking.RadDock.LoadFromNewXml(XmlReader reader)
   at Telerik.WinControls.UI.Docking.RadDock.LoadFromXmlCore(XmlReader reader, Boolean oldXmlFormat)
   at Telerik.WinControls.UI.Docking.RadDock.LoadFromXml(String fileName)
   at TELMDI.Form1.LoadSavedLayout()

and the radDock1_LoadedFromXml never fires.

When I check my raddock1.MDIChildren they all appear to be there and they are also correctly applied on screen.

But when I then try to add new MDIs I cannot set the parent to be this; so something obviously gets corrupted.

If instead I change the order so that I LoadContent and then set MDI I get 2 new windows and the following exception
                        input1 in1 = new input1();
                        in1.Text = e.DockWindow.Text;
                        ((HostWindow)e.DockWindow).LoadContent(in1);
                        in1.MdiParent = this;


'System.InvalidOperationException' occurred in Telerik.WinControls.RadDock.dll
14:26:09 DockWindowAdded input13=System.InvalidOperationException: Cannot reload content for a HostWindow, which is bound to a MDI Child.
   at Telerik.WinControls.UI.Docking.HostWindow.VerifyContentChange()
   at Telerik.WinControls.UI.Docking.HostWindow.LoadContent(Control content)
   at TELMDI.Form1.radDock1_DockWindowAdded(Object sender, DockWindowEventArgs e) in E:\VS2008 Projects\telerik_test\TELMDI\Form1.cs:line 153

Does anyone know the correct way of reloading MDI content after loadfromxml?

 Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 07 Mar 2011, 12:56 PM
Hi Graeme,

Thank you for your question.

When RadDock starts hosting an MDI Form, it actually breaks the mdi parent-child relation between the parent form and the child form. This is necessary, because an mdi child can't be inserted in the Controls collection of a DockWindow, hence hosted in it. You can easily check that the MdiChildren.Length of the parent form is 0 after RadDock starts hosting an mdi child form.

So, in your case, you do not need to set the MdiParent property of the form that you are trying to load in RadDock. This is the correct way of loading a form in RadDock.

I hope that this information helps.

Kind regards,
Nikolay
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Dock
Asked by
Graeme Lynch
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or