Page 1 of 1

listview sorting by clicking on column heading

Posted: Wed Oct 17, 2018 3:27 pm
by jsira2003@yahoo.com
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

Re: listview sorting by clicking on column heading

Posted: Wed Oct 17, 2018 3:36 pm
by jvierra
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.

Re: listview sorting by clicking on column heading

Posted: Wed Oct 17, 2018 3:41 pm
by jvierra
Example of sort and filter

Re: listview sorting by clicking on column heading

Posted: Thu Oct 18, 2018 10:24 am
by jsira2003@yahoo.com
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

Re: listview sorting by clicking on column heading

Posted: Thu Oct 18, 2018 11:40 am
by jvierra
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.