LoadFromXML MDI problems

2 posts, 0 answers
  1. Graeme Lynch
    Graeme Lynch avatar
    6 posts
    Member since:
    Aug 2009

    Posted 02 Mar 2011 Link to this post

    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;

    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;
                            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.
  2. Nikolay
    Nikolay avatar
    1802 posts

    Posted 07 Mar 2011 Link to this post

    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,
    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!
  3. DevCraft R3 2016 release webinar banner
Back to Top