unvell/ReoGrid

How to adjust column order by dragging and dropping columns

hs205118 opened this issue · 2 comments

Describe the feature

Hello, thank you for this great help in my program development. However, I have a feature that I don't know how to implement. Can you guide me?

I have columns A, B, C, and D. I hope to drag a column to the front or back of a specified column while holding down the top title of that column. Implement sorting methods such as A, C, D, and B.

And, my top customer header has a checkbox.

Which edition of ReoGrid is targeted

  • Windows Form

This is not a feature that can be implemented easily.

Moving the data of a column can be straightforward, but if you have merged cells or borders, there should be processes for how to split or combine merged cells, and how to handle the borders. Additionally, if you have formulas, you need to consider how the formula references change.

We may consider implementing this feature in future versions, but it may take some time.

@hs205118
I agree with @jingwood. It can get very complicated depending on the existing structure of the Grid.

Here is my suggestion how I would implement Column Reorder without any changes to the control itself.
1- Hook an event handler to the Reogrid.Mouseup and watch for right click
2- On Mouse Right Click event, open your own Form/Control that has a basic Listview or Listbox with the current column names. Enable Drag & Drop for reorder on your own control. Example : https://stackoverflow.com/questions/805165/reorder-a-winforms-listbox-using-drag-and-drop. Keep track of internal Column display indexes when closing your Form.
3- Rebuild your Reogrid contents from the underlying data with own code, under consideration of DisplayIndexes of the columns. The Column headers in Reogrid allow renaming, so to the user it will look like the column position changed. You need a list or dictionary object that keeps track of and maps Datacolumn vs DisplayIndex.