Jump to content

Sorting a listview by clicking on the header


MCP
 Share

Recommended Posts

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.

Link to comment
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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...