im using menu item as my navigation. and im using this to remove my menu.

Private Sub RemoveItemByValue(ByVal Value As String)
               For i As Integer = 0 To Menu1.Items.Count - 1
            If Menu1.Items(i).Value = Value Then
                Menu1.Items.Remove(Menu1.Items(i))
            End If

        Next
    End Sub

but i can only remove the top menu. but i want to remove the sub sub menu item.

Recommended Answers

All 2 Replies

Try to use Menu.FindItem method to search a menu item.

Assume that a menu has the following structure
Home->Music->Classical
Home->Music->Rock

Here Music has two sub menu items.

To remove the 'Classical' sub menu item from 'Music', use the following code

String valuePath1 = "Home/Music";
        MenuItem musicMenuItem = Menu1.FindItem(valuePath1);
        String valuePath2 = "Home/Music/Classical";
        MenuItem item = Menu1.FindItem(valuePath2);
        musicMenuItem.ChildItems.Remove(item);

it works! thanks a lot!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.