Add Form to ToolWindow after calling RadDock.LoadFromXml

8 posts, 0 answers
  1. Moe
    Moe avatar
    5 posts
    Member since:
    Oct 2009

    Posted 29 Jul 2010 Link to this post

    In my app I have 3 tool windows docked right/left/bottom respectively and I have one doc window in the middle. Our app support multiple display (different dock windows) where users can switch between display. I persisted each display settings in a separate xml file. My issue is how can I add me forms to the docked window/document after I load the proper xml setting file?
  2. Bernd Mueller
    Bernd Mueller avatar
    38 posts
    Member since:
    May 2010

    Posted 30 Jul 2010 Link to this post

    That should be possible with the normal DockControl function:

    RadDock1.DockControl(new RadForm(), UI.Docking.DockPosition.Fill, UI.Docking.DockType.Document)

     

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 06 Aug 2010 Link to this post

    Hello Mohamed,

    Indeed, you can dock a Form in RadDock by calling the DockControl method. However, this method will create a new instance of DockWindow.

    In order to host a Form in an existing DockWindow (which actually should be a HostWindow) you should call the LoadContent method of the HostWindow:
    ((HostWindow)this.radDock1.DockWindows[0]).LoadContent(formInstance);

    I hope this helps.

    Kind regards,
    Nikolay
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Sari
    Sari avatar
    5 posts
    Member since:
    Sep 2011

    Posted 17 Oct 2011 Link to this post

    Hello Nikolay,
    ((HostWindow)this.radDock1.DockWindows[0]).LoadContent(formInstance);
    Not work if radDock1.DockWindows[0]) is Telerik.WinControls.UI.Docking.ToolWindow.
    error System.InvalidCastException
  6. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 20 Oct 2011 Link to this post

    Hi Sari,

    If you use the API suggested above, the LoadContent method will be available, because the DockControl method creates windows of type HostWindow. In case you want to load a Form in a ToolWindow, you should use the following API:

    Form f = new Form();
    f.Show();
     
    f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
    f.TopLevel = false;
    f.Dock = DockStyle.Fill;
    this.radDock1.DockWindows[0].Controls.Add(f);

    I hope this helps.
    Kind regards,
    Nikolay
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

  7. Sari
    Sari avatar
    5 posts
    Member since:
    Sep 2011

    Posted 20 Oct 2011 Link to this post

    Hello Nikolay,

    I use the LoadContent metod. The LoadContent metod create the ToolWindow.
    1. I have an application with mdi forms.
    2. If create the mdi form that dockcontrol create document(host window)
    3. If  this host window is make docked, and then floating, that after radDock1.SaveToXml radDock1.LoadFromXml radDock created the host window
    4. !!! If  this host window is make floating immediately, that after radDock1.SaveToXml radDock1.LoadFromXml radDock created the tool window

    Therefore, there was a problem adding a form to an existing tool window.

    Thanks for your help

  8. Sari
    Sari avatar
    5 posts
    Member since:
    Sep 2011

    Posted 21 Oct 2011 Link to this post

    Hello Nikolay,

     

    Not work
    f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
     
  9. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 21 Oct 2011 Link to this post

    Hi Sari,

    In regards to your last comment, the FormBorderStyle property is a property of the standard Microsoft Form object. Therefore, if your point concerns complication, this property should always allow you to compile your project. Please note the the 'f' variable of of type Form. If this is not you have meant by saying that FormBorderStyle property does not work, I would kindly ask you to provide us with additional details about your case. As a general recommendation, I would kindly ask you to be more descriptive when you are trying to explain an issue. An explanation that is short of details may be associated with a huge number of scenarios and we may not be aware of which one exactly is yours. Therefore, a complete description of a case will allow both sides to help each other and as a result your will get a quicker and more accurate response. Thank you for your cooperation and understanding.

    As to the second to last message, I am not sure that I understand the meaning of the following sentence:
    "I use the LoadContent metod. The LoadContent metod create the ToolWindow." The LoadContent method loads controls inside the content area of a HostWindow. This method can't create any type of a DockWindow, so I suppose that you mean the DockControl method.

    Please note that in general, the DockControl method is not supposed to be used with MDI forms. The API that you should use in the MDI scenario is described here.

    Let's say that you dock your forms thanks to the DockControl method instead of the MDI API. If I understand your case correctly, you first make one of the DockWindows float. Then you save the layout and try to load it afterwards. In this case all the created DockWindows should be of type HostWindows. I am attaching a sample project which demonstrates how this scenario works.

    In case you need further assistance, please open a new support ticket and send us a sample project which demonstrates your scenario. In addition, describe the exact steps that we should follow in your project and the exact goal that you want to achieve. This will allow us to assist you further.

    Greetings,
    Nikolay
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

Back to Top
UI for WinForms is Visual Studio 2017 Ready