This is a migrated thread and some comments may be shown as answers.

How to find my RadListControl item from RadMenuItem event

1 Answer 109 Views
Menu
This is a migrated thread and some comments may be shown as answers.
pogy
Top achievements
Rank 1
pogy asked on 30 Mar 2014, 01:01 PM
This is my RadMenuItem event after choose item from RadListControl:

        private void menuItemRemveFromList_Click(object sender, EventArgs e)
        {

        }

All i want to do is to catch my RadListControl item index and RadListControl item text.
How can i do that ?

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 02 Apr 2014, 09:16 AM
Hello Pogy ,

Thank you for writing.

To achieve the desired functionality, you can store the clicked item when the menu is shown and then use it in the  menu item Click event. For example, you can remove a particular item by clicking a context menu item with the following code:
RadListVisualItem currentItem = null;
 
void radListControl1_MouseDown(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.Right)
    {
        RadListVisualItem clickedItem = radListControl1.ElementTree.GetElementAtPoint(e.Location) as RadListVisualItem;
        if (clickedItem != null)
        {
            currentItem = clickedItem;
            contextMenu.Show(this.radListControl1, e.Location);
        }
    }
}
 
void menuItem1_Click(object sender, EventArgs e)
{
    if (currentItem != null)
    {
        radListControl1.Items.Remove(currentItem.Data);
    }
}

If you have any questions, please do not hesitate to contact us.
 
Regards,
Dimitar
Telerik

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Menu
Asked by
pogy
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or