clearing a sub-menu

Is there a quick way to dynamically delete all items in a sub-menu?

I’m using a MenuClear method to remove and Nil out dynamically created menus. You may use something similar to this:

Sub imContextMenuClear() // Clear Contextual Menu If Me.mBase <> Nil Then Dim j As Integer = Me.mBase.Count-1 For i As Integer = j DownTo 0 Me.mBase.Remove(i) Next Me.mBase = Nil End If End Sub

Reference to the other discussion on dynamic sub-menus, an alternative may be setup all the MenuItems on the menu bar and sub-menu MenuItems at design time and then at run time set the “Visible” property of each sub-menu MenuItem to “True” or “False” as needed.

Thanks, Oliver, but I’m trying to figure out how Me.mBase is the menu item.
Also, I’ve used Remove before, but it didn’t actually remove the item; it just cleared it and left a blank item.

Syed, the menu and all of the basic menu items are created in the IDE. Only the submenu items are added and deleted at run time.

Again, thanks, Oliver. I got it working in my program, and Remove now actually removes the menuitem. Don’t know why it only cleared the entry when I used it previously. Could it be that I was deleting menu items and now I’m deleting submenu items?

MenuItems vs submenuitems its all the same kind of thing
Just attached to each other in different spots
No magic