Q

In VB.NET, how do I unload all forms within forms and return to parent form?

In VB.NET, how do I unload all forms within forms and return to parent form?
Ah ha, an interesting situation -- this assumes that the form you want to do this from is in fact within an MDIform. Normal forms can't act as a container towards other forms unless setting the MDIParent property. They also require the parent to have the property 'IsMDIContainer' set to true on the parent.

The following snippet of code should be placed in a procedure somewhere in your code to do what you require.

        If Not Me.MdiChildren Is Nothing Then
            Dim _pointertoForm As System.Windows.Forms.Form
            For Each _pointertoForm In Me.MdiChildren
                x.Close()
            Next
        End If

Hope that sorts out your little problem.

This was first published in March 2003

Dig deeper on Win Development Resources

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close