DocumentWindow defined in separat file

2 posts, 0 answers
  1. Peter Kraus
    Peter Kraus avatar
    1 posts
    Member since:
    Feb 2010

    Posted 23 Jul 2015 Link to this post

    I implemented a WinForm holding a RadDock and in it several Containers, DocumentWindows, ...

    Now that there are more and more specialized DocumentWindows I think about defining this windows in separate files and loading this DocumentWindows dynamically when need to be shown.

    Could you guid me how to do this easy and elegant?


    How can I move the definition of the DocumentWindows into another file?

    Generating a new nearly empty WinForm with a RadDoc and copyPaste the Window into that?

    How can I load the DocumentWindow dynamically into the main WinForm?

    Not all documentWindows are shown after program start, but when the user is selecting it in main menu "View" - just like it is in MS VS.




  2. Stefan
    Stefan avatar
    2911 posts

    Posted 24 Jul 2015 Link to this post

    Hello Peter,

    Thank you for writing.

    You can use two approaches for the purpose:
    1. Define the contents of the different DocumentWindows in UserControls and then when needed, add the UserControl to a DocumentWindow instance and add the latter to RadDock. This approach will give you the flexibility to populate your UserControls at design time.
    2. You can create descendants of DocumentWindow and programmatically populate them with the desired controls, then add them to RadDock when needed. Here is an example:
    protected override void OnLoad(EventArgs e)
        radDock1.AddDocument(new DocumentWindow1());
        radDock1.AddDocument(new DocumentWindow2());
    class DocumentWindow1 : DocumentWindow
        public DocumentWindow1()
            this.Controls.Add(new RadButton() { Text = "button" });
    class DocumentWindow2 : DocumentWindow
        public DocumentWindow2()
            this.Controls.Add(new RadLabel() { Text = "button" });

    In both cases, the UserControl or the DocumentWindow declarations can be in separate files.

    Initially, you can add all the windows to RadDock. Then you can hide the ones that you do not want to display, by setting their DockState to Hidden. To show them back, set their DockState to Docked or TabbedDocument.

    You can also use the Show/Close methods, but before that you have to set the CloseAction property to Hide, so the windows don't get disposed on close.

    I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

    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 Feedback Portal and vote to affect the priority of the items
Back to Top