-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Enhance DataGridView to support non-destructive (multi column) Sort #5202
Comments
@RussKie could you please transfer? @coderb not sure if this will help but it sounds similar to your problem https://social.msdn.microsoft.com/Forums/vstudio/en-US/8fc635e2-9994-4214-9c89-43b3acf528e1/c-sorting-a-datagridview-by-one-column-then-by-another?forum=winformsdatacontrols |
@krwq nope, that link is a no go. i need to be able to (continue to) use the column headers to do the sorting. i've tried everything i could find on the web/stack overflow and even tried doing some reflection to SortInternal when overriding the Sort() method of DataGridView but it doesn't like to be passed both a column and comparer object. it seems like some code support in DataGridView is appropriate. |
i've requested that the dotnet core project add a stable sort algorithm. |
@corerb winforms/src/System.Windows.Forms/src/System/Windows/Forms/DataGridViewRowCollection.RowArrayList.cs Line 35 in d46ad2e
Also, it should be fairly straightforward to modify the compare function to take the current order into account. It may take a bit extra memory (e.g. temporary array of integers). It is negliable given how much memory is occupied by each row. |
This issue is now marked as "up for grabs", and we’re looking for a community volunteer to work on this issue. If we receive no interest in 120 days, we will close the issue. To learn more about how we handle feature requests, please see our documentation. Happy Coding! |
@KlausLoeffelmann this sounds like a useful feature, thoughts? |
Hmm. I am a bit torn, also since Data Binding might be an issue here, since - if I remember correctly - sorting will then be delegated to a For unbound data sources, I would think implementing a So, I don't know. Am I missing something else which should justify this feature? |
I am moving this to future. We won't have the bandwidth in the nearer future to address this. |
DataGridView.Sort
seems to be implemented via the quick sort algo inDataGridViewRowCollection.RowArrayList
.I would like to be able to sort the DataGridView in a non-destructive (stable) way when changing the sort column (clicking the header to sort). Eg. If I sort on the first column and then sort on the second, the rows remain sorted by column 1 for equal values of column 2.
The text was updated successfully, but these errors were encountered: