vb.net visibility o form objects
-
In a VB.NET 2008 desktop application, I need to add some initial selections with a corresponding button to the 'main' form, before any of the normal processing is allowed to occur. Thus due to that fact, I have the following questions to ask: 1. This application is using a System.Windows.Forms.MainMenu and I would like the 'File' option to not display until the 'new' button is clicked? If this is possible, would you showe me the code for this to occur? 2. If option #1 is not possible, is there a way to make System.Windows.Forms.MainMenu not display until the the 'new' button is clicked? If this is possible, would you show me the code for this to occur? 3. In this application there is code that adds menu items with logic like,
MainMenu1.MenuItems(0).MenuItems.Add("New Item", New EventHandler(AddressOf ClickHandler)) MainMenu1.MenuItems(0).MenuItems.Add("-")
Is there a way to modify the order of list of menuitems after the menu items have already been created? Would I need to delete the menuitems at that point and create the menuitems again? Thus would you show me the code for this option and/or let me know if this option is not possible?
-
In a VB.NET 2008 desktop application, I need to add some initial selections with a corresponding button to the 'main' form, before any of the normal processing is allowed to occur. Thus due to that fact, I have the following questions to ask: 1. This application is using a System.Windows.Forms.MainMenu and I would like the 'File' option to not display until the 'new' button is clicked? If this is possible, would you showe me the code for this to occur? 2. If option #1 is not possible, is there a way to make System.Windows.Forms.MainMenu not display until the the 'new' button is clicked? If this is possible, would you show me the code for this to occur? 3. In this application there is code that adds menu items with logic like,
MainMenu1.MenuItems(0).MenuItems.Add("New Item", New EventHandler(AddressOf ClickHandler)) MainMenu1.MenuItems(0).MenuItems.Add("-")
Is there a way to modify the order of list of menuitems after the menu items have already been created? Would I need to delete the menuitems at that point and create the menuitems again? Thus would you show me the code for this option and/or let me know if this option is not possible?
-
1. Set the menu item's visibility property to
False
so it will not show on the form. You then set it toTrue
when required. 2. NA 3. You would need to delete them and re-insert them.In response to your answers, I have the following questions: "Set the menu item's visibility property to False so it will not show on the form. You then set it to True when required." I placed the following code in the application, and it did not work:
MainMenu1.MdiListItem.Visible = False
Thus can you show me the code to Set the menu item's visibility property to False? Also would you show me the code on how to 'You would need to delete them and re-insert them' the menuitems? The menu items are currently created in the gui and not in code.
-
In response to your answers, I have the following questions: "Set the menu item's visibility property to False so it will not show on the form. You then set it to True when required." I placed the following code in the application, and it did not work:
MainMenu1.MdiListItem.Visible = False
Thus can you show me the code to Set the menu item's visibility property to False? Also would you show me the code on how to 'You would need to delete them and re-insert them' the menuitems? The menu items are currently created in the gui and not in code.
classy_dog wrote:
can you show me the code to Set the menu item's visibility property to False?
The code you have should do it, I just tested it on my sample and it works fine. The menu items are created in code within the form designer, whose code can be viewed, so you can see how it is created. You can also read the MSDN documentation[^] for full details.