Click to See Complete Forum and Search --> : Child form not showing up in MDIcontainer's split Container


marinajogy
August 21st, 2008, 02:46 AM
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

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

HanneSThEGreaT
August 21st, 2008, 03:44 AM
Do not use the Splitcontainer here :)

Use the Splitter instead.

On your MDI Parent, remove the Splitcontainer.
Add the Splitter control ( from All Windows Controls in the Toolbox ), add your Treeview inside that Splitter.
This will ensure that your Treeview, always occupies the left side of your form, and your child forms will always show on the right.

I hope you come right :)

HanneSThEGreaT
August 21st, 2008, 04:22 AM
One more thing, please read this on how to post properly :

http://www.codeguru.com/forum/showthread.php?p=1474007#post1474007

marinajogy
August 21st, 2008, 04:35 AM
Do not use the Splitcontainer here :)

Use the Splitter instead.

On your MDI Parent, remove the Splitcontainer.
Add the Splitter control ( from All Windows Controls in the Toolbox ), add your Treeview inside that Splitter.
This will ensure that your Treeview, always occupies the left side of your form, and your child forms will always show on the right.

I hope you come right :)


thanksm, solved

HanneSThEGreaT
August 21st, 2008, 04:47 AM
That's good news :)

Just remember to mark your thread Resolved :)