To reproduce:
public Form1()
{
InitializeComponent();
this.radListView1.AllowDragDrop = true;
for (int i = 0; i < 3; i++)
{
this.radListView1.Items.Add("Item" + i);
}
this.radListView1.ListViewElement.DragDropService.Started += DragDropService_Started;
this.radListView1.ListViewElement.DragDropService.Stopped += DragDropService_Stopped;
}
private void DragDropService_Stopped(object sender, EventArgs e)
{
Console.WriteLine("Stopped " + this.radListView1.SelectedIndex);
}
private void DragDropService_Started(object sender, EventArgs e)
{
Console.WriteLine("Started " + this.radListView1.SelectedIndex);
}
Drag an item and drop it on a new position. As a result the SelectedIndexChanged event is fired and the new index is -1. There is no selected item in the RadListView.
Workaround: use a custom RadListView.ListViewElement.DragDropService and set the SelectedItem property to be equal to the CurrentItem when the drop operation is completed.
public class CustomService : ListViewDragDropService
{
public CustomService(RadListViewElement owner) : base(owner)
{
}
protected override void OnPreviewDragDrop(Telerik.WinControls.RadDropEventArgs e)
{
base.OnPreviewDragDrop(e);
this.Owner.SelectedItem = this.Owner.CurrentItem;
}
}