How to implement sorting in a list while saving adjacent columns?

I have a ListView that has multiple columns.

One of them contains “Names” and the other contains “Sum”. I would like to allow the user to click the “Names” column in the list and sort it alphabetically, and also to allow the user to click “Sum” and sort it digitally (above / below - below / above).

What is the best way to implement this?

+4
source share
3 answers

It is partially implemented, but not completely. Microsoft has a description of how to approach this problem at http://support.microsoft.com/kb/319401 .

+4
source

To solve this problem, I wrote my own ListViewItemComparer, which implemented the IComparer interface. Then, based on whether the column was numeric or string, I made an appropriate comparison.

+1
source

ObjectListView (the open source wrapper around .NET WinForms ListView) does just that for you automatically.

+1
source

Source: https://habr.com/ru/post/1277230/


All Articles