R
retrocoder
How to add dynamically new item WITH subitems to ContextMenuStrip?
I already have designer edited ContextMenuStrip on the form but I need
to add some items with sub-items to it dynamically on runtime. How to
do that?
I can add normal items with
myMenu.Items.Add("My new item");
But I have no idea how to add Item with sub-items.
Other question is, how can I get "Text" from sub-items and those new
dynamically created sub-items? I know I can do
Point p = myMenu.PointToClient(new Point(Form.MousePosition.X,
Form.MousePosition.Y));
ToolStripItem pItem = myMenu.GetItemAt(p.X, p.Y);
this.Text = pItem.Text;
But it only give text from main items, not from sub-items.
Any ideas are apreciated, thank you.
I already have designer edited ContextMenuStrip on the form but I need
to add some items with sub-items to it dynamically on runtime. How to
do that?
I can add normal items with
myMenu.Items.Add("My new item");
But I have no idea how to add Item with sub-items.
Other question is, how can I get "Text" from sub-items and those new
dynamically created sub-items? I know I can do
Point p = myMenu.PointToClient(new Point(Form.MousePosition.X,
Form.MousePosition.Y));
ToolStripItem pItem = myMenu.GetItemAt(p.X, p.Y);
this.Text = pItem.Text;
But it only give text from main items, not from sub-items.
Any ideas are apreciated, thank you.