Winforms panel won't show after I add a forms page to controls

60 Views Asked by At

In the code below I will check which node is selected. Based on that I will show different forms in the panel (which you can see in the picture). Now everything works fine beside when I try to show the panel it stays blank. Nothing will show when I add the form to the controls of the panel.

Private Sub CheckForChildren(ByVal node As TreeNodeAdv)
    ' check whether each parent node has child nodes 
    If node.HasChildren AndAlso node.Nodes.Count > 0 Then
        ' iterate through child nodes in the collection
        For Each childNode As TreeNodeAdv In node.Nodes
            If childNode.IsSelected Then
                Console.WriteLine(childNode.Text & " is selected")
                If childNode.Name = "cnKlanten" Then
                    pnlHome.Controls.Clear()
                    Dim form As frmClients = New frmClients
                    form.Dock = DockStyle.Fill
                    form.TopLevel = False
                    pnlHome.Controls.Add(form)
                    pnlHome.BringToFront()
                    pnlHome.Show()
                End If
            End If
            ' Do recursive call
            CheckForChildren(childNode)
        Next childNode
    End If
End Sub

Layout application

I tried hiding it first which doesn't seem to help. I also have read a couple related post on here and other forums. And I also watched some videos on YouTube. But all of them just show me how I did it but their panel will show and I can't see any difference.

0

There are 0 best solutions below