I know to sort in datagridview by sorting on column heading is difficult. It is easier to do this in listview? Also with listview can i just add a datasource with any array such as:
$lvtable.datasource = $myarray
thanks,
John
listview sorting by clicking on column heading
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- jsira2003@yahoo.com
- Posts: 117
- Last visit: Tue Jul 11, 2023 6:18 am
Re: listview sorting by clicking on column heading
A DataGridView based on a table source is completely sortable on any column by default.
The ListView control is not data enabled for items. Sorts on a ListView have to be custom coded.
The ListView control is not data enabled for items. Sorts on a ListView have to be custom coded.
Re: listview sorting by clicking on column heading
Example of sort and filter
- Attachments
-
- Demo-DGVSortFormat.psf
- (17.58 KiB) Downloaded 125 times
- jsira2003@yahoo.com
- Posts: 117
- Last visit: Tue Jul 11, 2023 6:18 am
Re: listview sorting by clicking on column heading
Well I got it working 90%. My only issue is I have a couple columns with numbers. They were declared as float and instead of sorting numerically, they sort as string text. Any idea why a couple of my columns do not sort correctly? All my columns are floats.
thank you,
John
thank you,
John
Re: listview sorting by clicking on column heading
You have to make the columns into numbers and not text. Only numeric values will sort as numbers.
Note that my example sorts the "length" column correctly.
Note that my example sorts the "length" column correctly.