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

RadContextMenu on ListView removing multiple items

1 Answer 258 Views
ContextMenu
This is a migrated thread and some comments may be shown as answers.
Henry
Top achievements
Rank 1
Henry asked on 30 Aug 2013, 04:40 PM
I have a RadContextMenu on a RadListView with 2 commands.  Add and Remove.  The Add works fine, but when I use the remove a few times, It removes the selected Index item in addition to the one above it.  The Item.text for the listview items are unique and that is how  I am removing them. 

Help!  I've been fighting this for 3 days.  Still clicking remove on 1 item results in multiple items being removed. 

A good example of the radMenuItem1_Click event would be very useful.

Thanks,
-Henry

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 04 Sep 2013, 02:03 PM
Hi Henry,

I am not sure what might be causing this in your case. Here is a small example which seems works as expected on my end:
RadContextMenu contextMenu = new RadContextMenu();
 
public MainForm()
{
    InitializeComponent();
 
    RadMenuItem menuItem = new RadMenuItem("Delete");
    menuItem.Click += new EventHandler(menuItem_Click);
 
    contextMenu.Items.Add(menuItem);
 
    radListView1.MouseDown += new MouseEventHandler(radListView1_MouseDown);
}
 
void menuItem_Click(object sender, EventArgs e)
{
    foreach (ListViewDataItem item in radListView1.SelectedItems.ToList())
    {
        radListView1.Items.Remove(item);
    }
}
 
void radListView1_MouseDown(object sender, MouseEventArgs e)
{
    if (e.Button == System.Windows.Forms.MouseButtons.Right)
    {
        contextMenu.Show(radListView1, e.X, e.Y); 
    }
}

If you continue experiencing issues, please provide me with a snippet of your code and I will gladly look into it.

Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
ContextMenu
Asked by
Henry
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or