dotnetmonitor.com

 
Index
Previous
Next

 

When thinking about Merging, it is often convenient to describe the action in terms of a target and source:

 

Target - this is the ToolStrip you're merging into (e.g. a Main MenuStrip on your form)

Source - this is the ToolStrip with items you want to merge into the Target toolstrip. (e.g. a menu from an MDI child from)

Merge Action

 

The merge action should be set on items in the "Source" toolstrip - e.g. your MDI child menu strip.

 

Append

(default) adds the Source item to the end of the Target Items collection

Insert

  • adds the Source item to the Target Items collections as specified by the MergeIndex property set on the Source Item.

Replace

  • finds a match (using Text property, then MergeIndex if no match), then replaces the matching Target Item with the Source Item.
  • (e.g, MDI child item replaces item from MainMenuStrip)

MatchOnly

  • finds a match (using Text property, then MergeIndex if no match), then adds all the Source Item's DropDownItems to the Target Item.
  • (e.g. an MDI child wants to add a menu item to MainMenuStrip's Save As-> menu).

Remove

  • finds a match (using Text property, then MergeIndex if no match), then removes the item from the Target ToolStrip.
  • (e.g. MDI child can remove the save menu item from MainMenuStrip).
  •  

Note the usefulness of MatchOnly - it can be used to build up a menu structure to insert/add/remove into a submenu. The most frequently used MergeActions will be MatchOnly, Append, and Insert.

Painting
When should I use Paint/OnPaint and when should I override the ToolStripRenderer?
Do I need to worry about double buffering?
Parenting
Partial Trust
Usage