Click here to Skip to main content
11,708,312 members (73,365 online)
Rate this: bad
good
Please Sign up or sign in to vote.
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.

Thanks

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);
 

            }
        }
    }
    Tree.ExpandAll();
}
Posted 19-Sep-12 22:52pm
Edited 20-Sep-12 10:20am
Nueman9.1K
v5

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  

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

  Print Answers RSS
0 Maciej Los 245
1 Sergey Alexandrovich Kryukov 189
2 Mika Wendelius 180
3 Peter Leow 130
4 OriginalGriff 103
0 OriginalGriff 9,253
1 Sergey Alexandrovich Kryukov 8,562
2 CPallini 5,189
3 Maciej Los 4,966
4 Mika Wendelius 3,856


Advertise | Privacy | Mobile
Web01 | 2.8.150819.1 | Last Updated 20 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100