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

Drag and Drop Row

2 Answers 129 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 1
Jay asked on 04 Mar 2013, 08:09 PM
I'm following the example in the attached file here to drag and drop rows. In the PreviewDragDrop() event, the example casts e.DragInstance to a GridDataRowElement.

var rowElement = e.DragInstance as GridDataRowElement;
if (rowElement == null)
    return;

However, I never get a GridDataRowElement, I always get a SnapshotDragItem, so rowElement is always null.

How do I get the row element?

2 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 07 Mar 2013, 12:59 PM
Hello Jay,

Thank you for writing.

I have tested the project in the mentioned article, however, the type of the DragInstance in the dragDropService_PreviewDragDrop event handler is GridDataRowElement, not SnapshotDragItem. However, on other cases of drag and drop (like row reordering for example) it is possible that you end up with this type. In was recently introduced to help us improving some features in the control. Here is how to get the dragged object from the snapshot item:
GridDataRowElement row = ((SnapshotDragItem)e.DragInstance).Item as GridDataRowElement;

I hope that you find this information useful.

All the best,
Stefan
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
0
Jay
Top achievements
Rank 1
answered on 07 Mar 2013, 04:15 PM
That works beautifully.

Thanks a lot Stefan.
Tags
GridView
Asked by
Jay
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Jay
Top achievements
Rank 1
Share this question
or