My app dynamically adds/removes menu items at run-time. My removal code looks like this:
while (menu.DropDownItems.Count > 0) {
menu.DropDownItems[0].Dispose();
}
This works fine, because ToolStripItem.Dispose says this.Owner.Items.Remove(this); (verified with ILSpy).
My question is: Is it good form to rely on the fact that ToolStripItem.Dispose also removes the item from the menu? The documentation for ToolStripItem.Dispose does not mention this fact.
This is actually the default behavior of the
Controlclass, so it goes a bit further than justToolStripItem. I am using this method in my code as well.