RadDock has the capability of automatically finding and attaching Multiple Document Interface (MDI) child forms as tabbed documents. Since RadDock takes control over the MDI children, these children are not added to the parent form's MdiChildren collection, but they are added to the RadDock.MdiChildren collection instead.
To configure your MDI application to use this feature:
- First designate which form that will act as MDI container. Set the parent form IsMdiContainer property to true. This can be done at design time or in code (see code example below).
- Drop a RadDock onto the parent form and set the AutoDetectMdiChildForms property to true. You may also want to set the RadDock.Dock property to Fill to get the best use of space on the form.
Copy[C#] Configuring the Parent Form
private void Form1_Load(object sender, EventArgs e)
{
this.IsMdiContainer = true;
this.radDock1.AutoDetectMdiChildren = true;
}
Copy[VB.NET] Configuring the Parent Form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.IsMdiContainer = True
Me.RadDock1.AutoDetectMdiChildren = True
End Sub- Add a form to the project that will serve the role of child form. No properties, methods or event handlers need to be set for this form, except that you may want to add some content that will be visible when the child forms are displayed as tabbed documents.
- Add code to the parent form to create the child form and assign it an MDI parent:
Copy[C#]
private void radMenuItem1_Click(object sender, EventArgs e)
{
Form childForm = new Form();
childForm.Text = "MDI Child " + DateTime.Now.ToShortTimeString();
childForm.MdiParent = this;
childForm.Show();
}
Copy[VB.NET]
Private Sub RadMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadMenuItem1.Click
Dim childForm As New Form()
childForm.Text = "MDI Child " & DateTime.Now.ToShortTimeString()
childForm.MdiParent = Me
childForm.Show()
End Sub
MdiChildrenDockType
This property allows you to determine the default type of the DockWindows that will be created for the MDI children forms. By default these DockWindows are DocumentWindows.
However, you can set the default type to ToolWindow:
Copy[C#] Setting the default DockWindow type for MDI children forms
this.radDock1.MdiChildrenDockType = DockType.ToolWindow;
Copy[VB.NET] Setting the default DockWindow type for MDI children forms
Me.RadDock1.MdiChildrenDockType = DockType.ToolWindow
When initially created, these ToolWindows look like DocumentWindows. This is just because their state is Tabbed Document. However, their real identity is ToolWindow - i.e. these windows can be docked, auto-hidden and floated.