Thanks to previous advice, I'm nearly there - How can I get the Rowhandle of the row which started the drag drop. I need it to deal with the data I'm handling, and to ensure that the Drop is always on the same row.
Can I get this within the behaviour routines, or do I need to store using a MouseDown?
Thanks.
Hello Bob,
From what I gather, you need to obtain the row handles of a source grid in the DragDropBehavior.DragDrop event. If so, use the DragDropEventArgs.Data property or the DragDropEventArgs.GetData method to obtain source row handles. This approach is illustrated in the following example - How to reorder grid rows by drag and drop:
int[] sourceHandles = e.GetData<int[]>(); int targetRowHandle = hitInfo.RowHandle; int targetRowIndex = targetGrid.GetDataSourceRowIndex(targetRowHandle); List<DataRow> draggedRows = new List<DataRow>(); foreach (int sourceHandle in sourceHandles) { int oldRowIndex = sourceGrid.GetDataSourceRowIndex(sourceHandle); DataRow oldRow = sourceTable.Rows[oldRowIndex]; draggedRows.Add(oldRow); }
If your task is different, please describe it in detail, and also send us a simple example illustrating your implementation and requirements. This will help us narrow down the issue and find its cause quickly.
I look forward to your results.
Thanks for reply. I looked at this, but I need the source rowhandle during the drag operation (so that I can show that the drop cannot take place if the mouse moves away from the source row to another. (We are doing stuff that relates to a single row, so the dragdrop will always be from one column to another within the same row).
Thanks.