radDropdownMenu

2 posts, 0 answers
  1. Erik
    Erik avatar
    80 posts
    Member since:
    Jul 2007

    Posted 30 Jul 2008 Link to this post

    Hi Telerik,

    I added RadDropDownMenu to every node in tree view.

    Code:
    dim MenuItem1 as new Telerik.Wincontrols.UI.RadMenuItem
    dim MenuItem2 as new Telerik.Wincontrols.UI.RadMenuItem

    MenuItem1.text="Test Drop Down Menu1"
    dropdownmenu.items.add(MenuItem1)

    MenuItem2.text="Test Drop Down Menu2"
    dropdownmenu.items.add(MenuItem2)

    My question is how to get the index of the MenuItem1 or MenuItem2 when you click the RadDropDownMenu?

    Thanks

  2. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 01 Aug 2008 Link to this post

    Hi Erik,

    If you look at the code of the RadTreeView context menu example in the Quick-Start application you will notice the following method:
    private void radMenuItem_Click(object sender, EventArgs e) 
            {    
                RadMenuItem item = sender as RadMenuItem; 
     
                if (item != null
                { 
                    label3.Text = this.clickedNode; 
                    label4.Text = item.Text; 
                } 
            } 

    Here, the important part is that the sender is actually the menu item, so you can use it to find its index in the Items collection of the menu (using the IndexOf method).

    Hope that helps.

    Regards,
    Jordan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top