I am developing a MDI application in c#. I am having trouble when two MenuStrip are combined:
I have the parent Parent Form
with its MenuStrip parentMenu
and some ToolStripMenuItem
elements: Option1
, Option2
.
Then I have a child Form
with its MenuStrip parentMenu
and two ToolStripMenuItem
elements: Option1
and OtherOption
. The merging propierties of these are match-only for Opcion1
and append for OtherOption
Now, here is the problem: When the child form is showed and the two MenuStrip
are combined, the event parentMenu.ItemAdded is tiggrered because OtherOption
is added to the parentMenu.Items
collection. This is not the case for Option1
. Notice that there may be some elements in Option1.DropDownItems
(in the child form) that are not present in the Option1.DropDownItems
in the parent form.
How can I get notified about these items that being added?
(Just for clarity: Suppose that parentMenu.Items
only contains a ToolStripMenuItem Option1
which only contains a ToolStripMenuItem
, say 'optionA'. Suppose that childMenu.Items
only contains a ToolStripMenuItem Option1
which only contains ToolStripMenuItem optionB
. When the two menus merge, how can I get notified about the item optionB being added the the father? Or how can I get notified about two menus merging, knowing which elements are new?).
"MenuStrip merging moves menu items from one ToolStrip to another rather than cloning them, as was the case with MainMenu." See here .
Because it is moving them rather than cloning them, try the OwnerChanged
event on the ToolStripItem
. Hook up to this event for each of your items and it will notify you when it is moved to another toolstrip.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.