How to create your menu during runtime
Step 1
Now you will create a menu at runtime, all you need to do is use the following code and put it in a button command or a menu. In this example we will use a submenu.
This is an example of a menu before you activate your runtime menu
Step 2
Once you click on your menu it will become something like this. Your File menu has been changed to Tools
Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem5.Click
Dim rtmenu = New MainMenu()
Dim rtmenuitem = New MenuItem()
rtmenuitem = New MenuItem("Tools", New System.EventHandler(AddressOf MenuItem2_Click))
rtmenuitem.MenuItems.Add("&Test", New System.EventHandler(AddressOf MenuItem2_Click))
rtmenu.MenuItems.Add(rtmenuitem)
Me.Menu = rtmenu
End Sub
No comments:
Post a Comment