0

Hey

This is going to be hard to explain but oh well....


I have a form with a menu. When I hit option one, it opens another form (form2) inside that same form (mdiparent). When I hit X on form2, then try to open it again from the original form with a menu thru the menu, It says it cant access a disposed object. Here is the code:

Form1:

Public Class Form1
    Dim f As New Form2

    Private Sub arandomname(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles stripMenuItem.Click
        f.MdiParent = Me
        f.Show()
    End Sub
....

Form2:
?

(The code above is just example. Dont worry about the names just the f and all that)
What do I do to fix it or make it all work?

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by __avd
0
Private Sub arandomname(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles stripMenuItem.Click

  If IsNothing(f) OrElse f.IsDisposed Then
            f = New Form()
            f.MdiParent = Me
            f.Show()
   End If
End Sub
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.