I have MenuStripwith some static elements. To this, MenuStripI add items programmatically. Some of these elements have child elements ( DropDownItems).
At some point, I would like to delete all the added items in order to recreate the menu with different items. How to do it right?
An example of a situation:
mainMenu
-staticItem1
-added1
-added1_sub1
-added1_sub2
-added2
-added2_sub1
I could do:
added1.Dispose();
mainMenu.Items.Remove(added2);
It all works, but I'm not sure if it is safe. Maybe I should delete and destroy all elements and sub-elements one after another recursively?
source
share