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

DocumentWindow defined in separat file

1 Answer 60 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Peter Kraus
Top achievements
Rank 1
Peter Kraus asked on 23 Jul 2015, 04:34 PM

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.

 

Thanx

Peter

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 24 Jul 2015, 05:51 AM
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)
{
    base.OnLoad(e);
 
    AddDock();
    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.

Regards,
Stefan
Telerik
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
Tags
Dock
Asked by
Peter Kraus
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or