Click here to Skip to main content
15,120,883 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

how can i convert string into toolstripmenu item?, any idea guys?

Prabhakaran Soundarapandian 28-Aug-12 0:26am
How your string content will be? any string example can you give because have to split that string....
D K N T H 28-Aug-12 0:31am
for example, the string contains the object name, now how can i convert this string into tool strip menu item,
Prabhakaran Soundarapandian 28-Aug-12 0:33am
Have a look on the my solution

1 solution

private void BuildMenuItems()
    ToolStripMenuItem[] items = new ToolStripMenuItem[2]; // You would obviously calculate this value at runtime.your splited string length goes here
    for (int i = 0; i < items.Length; i++)
        items[i] = new ToolStripMenuItem();
        items[i].Name = "dynamicItem" + i.ToString(); //You have to set your string value here
        items[i].Tag = "specialDataHere";
        items[i].Text = "Visible Menu Text Here";
        items[i].Click += new EventHandler(MenuItemClickHandler);


private void MenuItemClickHandler(object sender, EventArgs e)
    ToolStripMenuItem clickedItem = (ToolStripMenuItem)sender;
    // Take some action based on the data in clickedItem
D K N T H 28-Aug-12 0:37am
i like the idea, i'll try this later,. anyway, what object is myMenu ?
Praveen Kullu 28-Aug-12 0:55am
myMenu would be MenuStrip

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900