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

Dock a form on the MDI parent from a child form

1 Answer 213 Views
Dock
This is a migrated thread and some comments may be shown as answers.
William Willson
Top achievements
Rank 1
William Willson asked on 29 Nov 2010, 10:47 PM
Hi,

  I'm trying to figure out a good way to dock a form onto an MDI Parent RadDock from a child form.  The method I have been using is as follows:

Dim dockOpen As Integer = 0

For Each checkdoc As DockWindow In RadDock1.DockWindows.DocumentWindows
      If checkdoc.Name = "NameofForm1" Then
                  dockOpen = 1
      End If
Next

If dockOpen = 0 Then
    'Open Form
    Dim OpenForm As new NameofForm()
    OpenForm.Text = "Form Title"
    RadDock1.DockControl(OpenForm, UI.Docking.DockPosition.Fill, UI.Docking.DockType.Document)

    Dim dockable As DockWindow = GetDockableByName("NameofForm1")
    If Not dockable Is Nothing Then
        Me.RadDock1.ActiveWindow = dockable
    End If
Else
    Dim dockable As DockWindow = GetDockableByName("NameofForm1")
    If Not dockable Is Nothing Then
        Me.RadDock1.ActiveWindow = dockable
    End If
End If

This works fine when I call it from within my MDI Parent form.  The problem is from my Child Form I can't see 'RadDock1' or 'GetDockableByName'.  Can anyone help me out?

Thanks,
Will

1 Answer, 1 is accepted

Sort by
0
William Willson
Top achievements
Rank 1
answered on 30 Nov 2010, 03:47 AM
I managed to answer this myself, and found the answer in a 2009 post.  In case anyone needs this in the future, the resolution is as follows:

Public Class Form2  
    Dim hostParent As HostWindow  
 
    Private Sub Form2_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load  
        hostParent = Me.Parent  
    End Sub 
 
    Private Sub RadButton1_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles RadButton1.Click  
        If hostParent IsNot Nothing Then 
            Dim f3 As Form3 = New Form3  
            hostParent.DockManager.DockControl(f3, DockPosition.Left, DockType.Document)  
        End If 
    End Sub 
End Class 

Thanks,
Will
Tags
Dock
Asked by
William Willson
Top achievements
Rank 1
Answers by
William Willson
Top achievements
Rank 1
Share this question
or