Dumb question as it seems I have a lot of.....I have an app using mdi dropdown menu's that open various forms. When a new item is chosen, I want the old window to close (If the user did not use the quit button on the form). How do I do this and where?
maybe you should not be using MDI for your application. Remember M in MDI stands for Mutiple.
Anyway, here is one way to do it. (Although I think there is a proper way, but do not remember what it is.)
Private frmActive As Windows.Forms.Form
...
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
Try
frmActive.Close()
Catch
End Try
Dim x As New frmColorText()
frmActive = x
x.MdiParent = Me
x.Show()
End Sub
This will close the last window of the same menuitem that was opened. Add this to each menuitem with the same variable and it will keep only one window open at a time.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.