-
ListView ordering
Hi,
I have a multicolumn ListView control which I have created directly using the CreateWindowEx function. It has the LVS_REPORT style. I use LVM_INSERTITEM to add items and then LVM_SETITEMTEXT to set the individual columns.
However, LVM_INSERTITEM always adds new entries at the top of the list. Is there any way to get it to add them at the bottom?
-
Make sure you set the iItem member of the LVITEM struct to the required index.
See also The Old New Thing: Positioned vs. non-positioned listview views.
-
do something like this:
Code:
int iIndex = 0;
/* blah blah blah, switch statement case WM_COMMAND */
case IDM_ADD:
lvItem.iItem = iIndex;
/* blah blah blah, send the LVM_INSERTITEM message */
/* if the item was inserted, increment iIndex by 1 */
++iIndex;
/* return TRUE, break, whatever */
case IDM_REMOVE:
/* remove the item */
/* if the item removed successfully, decrement iIndex by 1 */
--iIndex;
/* return TRUE, break, whatever */
thats how I do it, its simple, but it does the trick ;) .