Ask the Expert

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

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

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: