I want to loop through all menu items and put the items to treeview. I used following code for this purpose. inforamtion
I have Transaction Menu and it has a Purchase Menu and purchase menu have
(Purchase invoice, Good Receive Note, etc). I want to get this items to treeview, under transaction, should have purchase and under purchase should have purchase invoice and good receive note
How can I do this..?
Please help me.
private void GetControlByName()
for (int i = 0; i < this.menuStrip1.Items.Count; i++)
string mnuItemName = this.menuStrip1.Items[i].Text;
Tree.Nodes.Add("", mnuItemName, 0, 2);
ToolStripMenuItem tmpMenuItem = this.menuStrip1.Items[i] as ToolStripMenuItem;
for (int j = 0; j < tmpMenuItem.DropDownItems.Count; j++)
string menuSubItem = tmpMenuItem.DropDownItems[j].Text;
if (menuSubItem != "")
Tree.Nodes[i].Nodes.Add("", menuSubItem, 1, 2);