The code below is for a custom menu strip. I am trying to figure out how to access the current open form so I may close it among other things. What I am basically trying to do is run "ActiveForm.Close()" when a user clicks to navigate to a new form, from the current one.
Thanks for your help!
Public Class MenuStripCustom
Inherits MenuStrip
Private WithEvents NavToolStrip As New ToolStripMenuItem("File")
Private WithEvents NavMainMenu As New ToolStripMenuItem("Main Menu")
Private WithEvents NavSignOut As New ToolStripMenuItem("Sign Out")
Private WithEvents NavExit As New ToolStripMenuItem("Exit")
Sub New()
Me.Items.Add(NavToolStrip)
NavToolStrip.DropDownItems.Add(NavMainMenu)
NavToolStrip.DropDownItems.Add(NavSignOut)
NavToolStrip.DropDownItems.Add(NavExit)
End Sub
' All forms
Private Sub NavExit_Click(sender As Object, e As EventArgs) Handles NavExit.Click
Application.Exit()
End Sub
Private Sub NavMainMenu_Click(sender As Object, e As EventArgs) Handles NavMainMenu.Click
'MainMenu.visible = true
'ActiveForm.Close()
End Sub
End Class
Edit: 'ActiveForm' is not defined for the class because this is a MenuStrip object. I'm unsure of how to access the current form through this class, when I put this object on a form. I commented out what I was trying to do at the bottom of the code. Sorry for confusion.