I have a Form that has a menu called MenuEdit
, with a ToolStripMenuItem called MenuEditElement
inside. When I right click on a listview, I want to create a Context Menu dynamically, containing EditElement, among other things. I'm doing it like this:
Dim CM As New ContextMenuStrip
Dim Submenu As ToolStripMenuItem = CM.Items.Add("New", ImageHolder.Images("New"))
CM.Items.Add(New ToolStripSeparator)
CM.Items.Add(MenuEditElement)
CM.Show(ListView, e.Location)
The problem is that, right after CM.Items.Add(MenuEditElement)
, MenuEditElement disappears from MenuEdit, as if it had been removed from there to be added to the context menu. Is there another way to do this?
I wouldn't want to be creating an identical menu to MenuEditItem, or to clone it. This is because MenuEditItem has 5 subitems, so I would have to create those too, along with attaching their handlers.
I'm using Framework 4.0.