Hello Wiliam,
Thank you for contacting Telerik Support.
RadListView supports Drag & Drop functionality. First you should enable the AllowDragDrop property for both of the RadListViews. As the build-in Drag & Drop behaviour
moves listViewItems to the target location with user interaction only, it is necessary to subscribe to the PreviewDragDrop event where you should make a copy of the selected Item. It is indispensable to handle the event in order to prevent removing the selected item from the first listView. The copy item should be added to the second listView. Please have a look at the following code snippet:
public
Form1()
{
InitializeComponent();
this
.radListView1.AllowDragDrop =
true
;
this
.radListView2.AllowDragDrop =
true
;
this
.radListView3.AllowDragDrop =
true
;
radListView1.ListViewElement.DragDropService.PreviewDragDrop += DragDropService_PreviewDragDrop;
radListView2.ListViewElement.DragDropService.PreviewDragDrop += DragDropService_PreviewDragDrop;
radListView3.ListViewElement.DragDropService.PreviewDragDrop += DragDropService_PreviewDragDrop;
}
void
DragDropService_PreviewDragDrop(
object
sender, Telerik.WinControls.RadDropEventArgs e)
{
e.Handled =
true
;
ListViewDataItem listViewDISender = (sender
as
ListViewDragDropService).DraggedItem
as
ListViewDataItem;
RadListView senderListView = listViewDISender.Owner.ElementTree.Control
as
RadListView;
IconListViewVisualItem originalItem = e.DragInstance
as
IconListViewVisualItem;
ListViewDataItem copyItem =
new
ListViewDataItem(originalItem.Text);
copyItem.Image = originalItem.Image;
IconListViewElement viewElement = e.HitTarget
as
IconListViewElement;
if
(viewElement !=
null
)
{
RadListView listViewControl = viewElement.ElementTree.Control
as
RadListView;
if
(listViewControl != senderListView)
{
listViewControl.Items.Add(copyItem);
}
}
IconListViewVisualItem visualItem = e.HitTarget
as
IconListViewVisualItem;
if
(visualItem !=
null
)
{
RadListView listViewControl = visualItem.ElementTree.Control
as
RadListView;
if
(listViewControl != senderListView)
{
listViewControl.Items.Add(copyItem);
}
}
}
The obtained result is displayed in drag&drop.png.
I hope this information helps. Should you have further questions, I would be glad to help.
Regards,
Desislava
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 >>