Sign in to follow this  
Followers 0
MCP

Sorting a listview by clicking on the header

3 posts in this topic

I would like to have my listview getting sorted each time I click on a header column.

If I have, for instance, the following:

...
Local $nListView_Width = 395
$lvHandle = GUICtrlCreateListView($L_GUI_LIST_COLUMNS, $x, 25, $nListView_Width, $nHeight, _
BitOR($LVS_SHOWSELALWAYS,  $LVS_NOSORTHEADER, $LVS_SORTASCENDING), _
BitOR($LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT))
_GUICtrlListView_SetColumnWidth($lvHandle, 0, $nListView_Width)
_GUICtrlListView_SetColumnWidth($lvHandle, 1, 700)
_GUICtrlListView_SetColumnWidth($lvHandle, 2, 160)
GUICtrlSetState($lvHandle, $GUI_DROPACCEPTED)
...

the listview items ares displayed in an ascending order based on the first column content, but that only works when I create the listview.

I need to be able sort the items by clicking on the different columns.

Share this post


Link to post
Share on other sites



I would like to have my listview getting sorted each time I click on a header column.

If I have, for instance, the following:

...
Local $nListView_Width = 395
$lvHandle = GUICtrlCreateListView($L_GUI_LIST_COLUMNS, $x, 25, $nListView_Width, $nHeight, _
BitOR($LVS_SHOWSELALWAYS,  $LVS_NOSORTHEADER, $LVS_SORTASCENDING), _
BitOR($LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT))
_GUICtrlListView_SetColumnWidth($lvHandle, 0, $nListView_Width)
_GUICtrlListView_SetColumnWidth($lvHandle, 1, 700)
_GUICtrlListView_SetColumnWidth($lvHandle, 2, 160)
GUICtrlSetState($lvHandle, $GUI_DROPACCEPTED)
...

the listview items ares displayed in an ascending order based on the first column content, but that only works when I create the listview.

I need to be able sort the items by clicking on the different columns.

Hi,

See Gary's post example;

replacement for _GUICtrlListView_SimpleSortBest, Randall

Share this post


Link to post
Share on other sites

See Gary's post example;

replacement for _GUICtrlListView_SimpleSortBest, Randall

Thank you. I am still upgrading to the external listview functions and still Gary's solution does not work for me, but it was very helpful indeed to look at his code. :) I am sure that that is the solution. ^_^

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0