Drag and Drop Row

3 posts, 0 answers
  1. Jay
    Jay avatar
    8 posts
    Member since:
    Aug 2012

    Posted 04 Mar 2013 Link to this post

    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)

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

    How do I get the row element?
  2. Stefan
    Stefan avatar
    2911 posts

    Posted 07 Mar 2013 Link to this post

    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,
    the Telerik team
    WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
  3. Jay
    Jay avatar
    8 posts
    Member since:
    Aug 2012

    Posted 07 Mar 2013 Link to this post

    That works beautifully.

    Thanks a lot Stefan.
Back to Top