I have a CListView
created via:
return CListView::Create(lpszClassName,
_T("ListView"),
dwStyle | LVS_SHOWSELALWAYS | LVS_ALIGNTOP | LVS_ICON | LVS_AUTOARRANGE,
rect,
pParentWnd,
nID,
pContext);
It displays the graphics of an attached CImageList
and has a text string under it.
In the past I've always just added items to the end of the list view and it shows up there. Today, I decided to insert the list view item to the first location instead, but it's still showing up at the end of the list view?
I insert the item via:
int debug=listctrl.InsertItem(0, mytexstring, imageindex);
The imageindex
is at the end of the CImageList
and the image added after adding the call above (why after instead of before, not sure, but that's how it is). debug comes back 0.
Once I do that, the new item is showing at the end of the list view and even scrolls the screen there when the list has a lot of items.
Shouldn't inserting the list view item to index 0 make it show up at the start?
What am I missing or doing wrong?
TIA!!
UPDATE:
If I do this:
listctrl.SetView(LV_VIEW_LIST);
listctrl.SetView(LV_VIEW_ICON);
It will work, but I don't think I should I have to do that?
You could try adding
| LVS_NOSORTHEADER
to the style to get the item inserted at the right place. I think this affects the default sorting behavior.