I have MenuStrip
with some static items. To this MenuStrip
I am adding items programmatically. Some of these items has child items (DropDownItems
).
At some point I would like to remove all added items to recreate menu with different items. How to do it right?
Example situation:
mainMenu
-staticItem1
-added1
-added1_sub1
-added1_sub2
-added2
-added2_sub1
I could do:
added1.Dispose();
mainMenu.Items.Remove(added2);
Both of this works, but I am not sure if it's safe. Maybe I should remove and dispose all items and subitems one by one recursively?