G
Guest
I begin a new form. I add a MenuStrip. I then right click it and select
"Insert Standard Items". This results in a loaded MenuStrip that contains
File>>New among others.
I then add a button and give it the following code.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Static b As Boolean
b = Not b
NewToolStripMenuItem.Visible = b
Debug.Print(NewToolStripMenuItem.Visible.ToString)
End Sub
This code toggles the visibility of the "New" menu item. This code works
correctly regarding the item visibility. Unfortunately, my Debug.Print
statement always prints "False" whether or not it is visible. Needless to
say, this causes me problems because I have sections of code that determine
what to do based upon a menu item being visible.
Can someone confirm this behaviour and suggest a different way for
determining if a menu item is visible. My only apparent alternative would be
to create a form level boolean variable that would shadow whether the menu
item is visible but this seems like a dumb way to resolve the issue.
Needless to say, this was not a problem with the old MainMenu control.
"Insert Standard Items". This results in a loaded MenuStrip that contains
File>>New among others.
I then add a button and give it the following code.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Static b As Boolean
b = Not b
NewToolStripMenuItem.Visible = b
Debug.Print(NewToolStripMenuItem.Visible.ToString)
End Sub
This code toggles the visibility of the "New" menu item. This code works
correctly regarding the item visibility. Unfortunately, my Debug.Print
statement always prints "False" whether or not it is visible. Needless to
say, this causes me problems because I have sections of code that determine
what to do based upon a menu item being visible.
Can someone confirm this behaviour and suggest a different way for
determining if a menu item is visible. My only apparent alternative would be
to create a form level boolean variable that would shadow whether the menu
item is visible but this seems like a dumb way to resolve the issue.
Needless to say, this was not a problem with the old MainMenu control.