PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Rolf Brandt on February 18, 2010, 01:46:44 PM

Title: Listview - Set and Retrieve Column Position
Post by: Rolf Brandt on February 18, 2010, 01:46:44 PM
Scenario:
A Listview with Header DragDrop, the user changes the order of columns. The order of columns should be saved and restored.

Question:
How can I retrieve the position of the column, and how can it be set programatically?
Title: Re: Listview - Set and Retrieve Column Position
Post by: José Roca on February 18, 2010, 02:52:57 PM
To get the current left-to-right order of columns:


DIM lpiArray(iCount - 1) AS LONG
SendMessage(hwndLV, %LVM_GETCOLUMNORDERARRAY, iCount, VARPTR(lpiArray(0)))


Where iCount is the number of columns and hwndLV the handle of the ListView.

To set the left-to-right order of columns use:


SendMessage(hwndLV, %LVM_SETCOLUMNORDERARRAY, iCount, VARPTR(lpiArray(0)))

Title: Re: Listview - Set and Retrieve Column Position
Post by: Rolf Brandt on February 18, 2010, 02:59:25 PM
Thank you, Jose. I was just checking through your wrappers in ListViewCtrl.inc and found

ListView_GetColumnOrderArray.

Thanks for the quick help.
Title: Re: Listview - Set and Retrieve Column Position
Post by: Rolf Brandt on February 18, 2010, 03:10:39 PM
Thanks again, Jose, works perfect!