|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ToolStripMenuItem Possible bug in VS2005"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. I've verified your results.
On top-level menu items which are always visible, reading .Visible works properly. On sub-menu items which are not currently displayed, reading .Visible always returns False, regardless of whether or not they *would* be visible once that item is displayed. Which kinda makes sense if you think about it, but it's not what you want. So yes, you will have to shadow the property in some way. You could toggle .Enabled to the same value and read it instead. genojoe wrote:
Show quoteHide quote > I begin a new form. I add a MenuStrip. I then right click it and select I've encountered the same problem and found the Available property.> "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. This seems to work in all cases.
Strange Issue / DB Error / Not Showing Error Message
VB.NET equivalent of C# Operator '??' Using For Each in a Custom collection class with hashtables Compiling for .NET Framework 1.x in VS 2005 Search for Directories/files/Folders Sql server express 2005 connections open When "As New" or not when instantiating? DataTable - Date Difference "using statments" Is there any way to Mount Virtual CD's from VB? |
|||||||||||||||||||||||