aqua
aqua

Reputation: 13

item not getting created at the end of list view control created using C++

I am trying to add an item at the end of list view control but its getting added to some random location in list view control created using C++. What may be the reason? I have attached the code below.

HWND hWndLocalList = GetDlgItem(hWnd, fileListName);
int itemno=ListView_GetItemCount(hWndLocalList);
LVITEM lvI;
memset(&lvI,0,sizeof(lvI));
lvI.mask      = LVIF_TEXT | LVIF_IMAGE |LVIF_STATE;
lvI.iItem  = itemno;
lvI.iSubItem  = 0;
lvI.state     = LVIS_SELECTED;
lvI.pszText   = "new folder";   
lvI.iImage=0;
int x=ListView_InsertItem(hWndLocalList, &lvI);

Upvotes: 1

Views: 93

Answers (1)

Jonathan Potter
Jonathan Potter

Reputation: 37192

My psychic powers tell me you have either the LVS_SORTASCENDING or LVS_SORTDESCENDING styles set on the Listview control. If you turn them off, the item will be added to the end.

Upvotes: 2

Related Questions