Child form not showing up in MDIcontainer's split Container

marinajogy

New member
Joined
Aug 21, 2008
Messages
1
Programming Experience
Beginner
hi see the code below
  1. i placed form and made it isMDIcontainer=true
  2. added treeview to this form and docked to left
  3. added split Container
  4. added 2 child forms namde Form3 & Form4

everything ok, except one thing the child forms not showing up
help me

VB.NET:
Public Class Form2
    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Call FillTreeView()
    End Sub

    Private Sub FillTreeView()
        Dim nodX As TreeNode
        Dim nodChild As TreeNode

        With tvwMenu
            .BeginUpdate()

            'Add the First Parent
            nodX = New TreeNode("Hardcoded elements")
            nodChild = New TreeNode("Child1")
            nodChild.Tag = "Form3"
            nodX.Nodes.Add(nodChild)
            nodChild = New TreeNode("Child2")
            nodChild.Tag = "Form4"
            nodX.Nodes.Add(nodChild)
            .Nodes.Add(nodX)
            nodX = Nothing

            'Add the parent for the dynamic elements
            nodX = New TreeNode("Dynamic elements")
            .Nodes.Add(nodX)
            nodX = Nothing

            .EndUpdate()
        End With
    End Sub

    Private Sub tvwMenu_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tvwMenu.DoubleClick
        Dim temp As String
        Try
            Select Case DirectCast(tvwMenu.SelectedNode.Tag, String)
                Case String.Empty
                    'Do Nothing
                Case "Form3"
                    Dim frm As New Form3()
                    temp = frm.Text
                    With frm
                        .MdiParent = Me
                        .FormBorderStyle = FormBorderStyle.None
                        .Show()
                        .Dock = DockStyle.Fill
                    End With
                Case "Form4"
                    Dim frm As New Form4()
                    temp = frm.Text
                    With frm
                        .MdiParent = Me
                        .Show()
                        .Dock = DockStyle.Fill
                    End With
                Case Else
                    MessageBox.Show("Houston, we have a problem!")
            End Select
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

        MessageBox.Show(temp)
    End Sub
End Class
 
Last edited by a moderator:
Mdi is managed by the dark grey MdiClient area you saw before you covered it with other controls. Your mdi children attaches to this and is hidden by the SplitContainer. Mdi will not work for such setup.
 
solucion

Try
Dim k As Integer


For k = 0 To My.Application.OpenForms.Count - 1
If My.Application.OpenForms.Item(k).Name <> "Form1" Then
My.Application.OpenForms.Item(k).Close()
End If
Next

Select Case DirectCast(tvwMenu.SelectedNode.Tag, String)
Case String.Empty
'Do Nothing
Case "Form3"
'Form3.Parent = Form1.SplitContainer1.Panel2

Dim frm As New Form3()
temp = frm.Text
With frm
.MdiParent = Me
.Parent = Me.SplitContainer1.Panel2
.FormBorderStyle = FormBorderStyle.None
.Show()
.Dock = DockStyle.Fill
End With
Case "Form4"
Dim frm As New Form4()
temp = frm.Text
With frm
.MdiParent = Me
.Parent = Me.SplitContainer1.Panel2
.Show()
.Dock = DockStyle.Fill
End With
Case Else
MessageBox.Show("Houston, we have a problem!")
End Select
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
 
Back
Top