Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to close an MDI child form in VB.NET

Status
Not open for further replies.

Rachefur

Programmer
Jul 23, 2003
5
US
Hi!
I have an MDI form and several child forms. From the MainMenu, I would like to actually close the child forms, not just bring them behind the active form. The code below is from the MainMenu. It shows frmPost but places the child forms behind it and does not close them. I would like to have child forms of different sizes but with this code, one form overlays another because the child form isn't closing.

Private Sub mnuPost_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPost.Click
Dim x As New frmSumChkReg
Dim y As New frmExtract
Dim z As New frmPost

x.Close()
y.Close()
x = Nothing
y = Nothing
z.MdiParent = Me
z.Show()
End Sub

Thanks!
 
Hi Nouman,
Thanks for the reply. I tried dispose() and it doesn't help. The forms still overlay each other.

Any other suggestions?

Thanks!
 
I don't know why u are instating the other Child Forms?
But to me the following code works
Add one MDI FORM Form1
Add two child form2,Form2
but a button on MDI and then check this Code
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim mYForm As Form
Dim yourForm As Form
mYForm = New Form3()
yourForm = New Form2()
yourForm.Close()
mYForm.MdiParent = Me
mYForm.Show()

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top