Link to home
Start Free TrialLog in
Avatar of xrok
xrok

asked on

Simple Code for .net - Best way to close child form

i have an MDI application with multiple child forms..how do i close any open child forms so that only one child form is open at a time...
Avatar of gopinathdeepak
gopinathdeepak

try this code...
assuming MDIParentForm1 to be an instance of the parent form in your mdi application,


dim i as integer = 0

for i=0 to MDIParentForm1.MdiChildren.GetLength(0)
    MDIParentForm1.MdiChildren(i).Close()
next

dim child1 as new childform1()
child1.MDIParent = MDIParentForm1
child1.Show()
Avatar of xrok

ASKER

how well does the Close function release the form object? i have critical memory management issues in my application..
ASKER CERTIFIED SOLUTION
Avatar of gopinathdeepak
gopinathdeepak

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Eduard Ghergu
Hello!
Unfortunatelly, there is no Forms collection in VB.NET... So, you have to create your own collection. You'll find an example at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vaconCreatingYourOwnCollectionClass.asp
Avatar of xrok

ASKER

i was afraid of that.  I will use hide instead.  ty