'How to Clone a ContextMenuStrip?

I need two contextMenuStrips with only textual differences, but it takes a few seconds to create and it causes lagging, so I don't want to create it again, and need to copy and modify its items to a new contextMenuStrip.

This is the example:

ContextMenuStrip context1 = new ContextMenuStrip();
context1.Items.Add(new ToolStripLabel("title"));
context1.Items.Add(new ToolStripSeparator());
context1.Items.Add(new ToolStripMenuItem("a"));
//..etc

I've tried to CopyTo() method but it will remove the context1's items:

ContextMenuStrip context2 = new ContextMenuStrip();
ToolStripItem[] copyItems= new ToolStripItem[context1.Items.Count];
context1.Items.CopyTo(copyItems, 0);
context2.Items.AddRange(copyItems);

I can't find a way to clone a ContextMenuStrip. Can anyone offer some help?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source