How to remove your MenuItem during RunTime
Step 1
To remove your menu item, you need to know the structure of your menu. In this tutorial we have File (menuitem1) menu. Then under file we have Help (menuitem2), test1 (menuitem4), test2(menuitem5), Delete Item (menuitem6)
Initially our menu look like this.
Step 2
Let’s say we will remove test1 from our menu. To do that, we need to go from MenuItem1 which is our main menu item. Then under it we have menuitem4. So to remove it we use the following code.
Private Sub MenuItem6_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem6.Click
MenuItem1.MenuItems.Remove(MenuItem4)
End Sub
Output from the menuitem that we have removed.
No comments:
Post a Comment