Bart van Tuyl
Bart van Tuyl

Reputation: 13

Cant unhide all child forms? vb.net

I have the flowing problem. I have a vb.net parent form with MDI children that contain sensitive information. I have made a pause button which should hide all child forms from sight, this is no problem, calling them back is. i have for testing purposes created a button which should do the reverse however all my child forms stay hidden can somebody assist?

Code to hide all child forms is as follows:

For Each frmApproval As Form In Me.MdiChildren
        frmApproval.Visible = False

    Next
    System_Paused.MdiParent = Me
    System_Paused.Show()

Now the form nammed System_Paused has a button on it which when clicked should revert the hidden child forms but its not working?

        For Each frmApproval As Form In Me.MdiChildren
        frmApproval.Visible= true
    Next
    Me.Close()

Upvotes: 1

Views: 652

Answers (1)

sloth
sloth

Reputation: 101142

You're iterating over the wrong MdiChildren collection.

You hide the children of your main form, but then you try to set the visibility of the children of the System_Paused form.

You could solve this issue by using something like this:

For Each frmApproval As Form In Me.MdiParent.MdiChildren
    frmApproval.Visible = true
Next

since you already set your main form as MdiParent of the System_Paused form.

Upvotes: 2

Related Questions