EnglishDescription-1

GridControl可以拖拽行吗

Description
I want to implement row reordering by drag and drop. How do i achieve this funtionality?

Solution
The order of grid rows is dependant on the sorting applied. So, to implement row reordering, you should create a column and apply sorting to it.
This approach is described in the How to allow an end-user to move the rows in a grid up and down if the grid is bound to a DataTable article.

To add the drag and drop functionality, do the following:
1. Handle the GridView.MouseDown event, and calculate the GridHitInfo object to determine if the data row is under the mouse pointer.
2. Handle the GridView.MouseMove event, and start the drag and drop operation.
3. Handle the GridView.DragOver event, and calculate the GridHitInfo object to determine if the row can be dropped.
4. Handle the GridView.DragDrop event to call the row move operation.

The sample project is attached.

posted @ 2010-06-01 15:18  Ry5  阅读(214)  评论(0编辑  收藏  举报