Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to adjust column order by dragging and dropping columns #512

Open
hs205118 opened this issue Dec 7, 2023 · 2 comments
Open

How to adjust column order by dragging and dropping columns #512

hs205118 opened this issue Dec 7, 2023 · 2 comments

Comments

@hs205118
Copy link

hs205118 commented Dec 7, 2023

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
@jingwood
Copy link
Member

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.

@CanadianHusky
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants