I need a way too find the item position by its text...
reason is, if you list directories for example and you want to add the numbers of files in it, if the listview is set to Autoarange and sortAscending the subitem doesnt get filled using the 0 positions method.
i've try to get the lv_finditem api message to work, but got no chance.
try this - it will search for "findme" string.
Message LVM_INSERTITEM returns item index, not sure if method InsertItem too...
LVFINDINFO li;
li.flags = LVFI_STRING;
li.psz = "findme";
int index = SendMessage(lv1->m_hwnd, LVM_FINDITEM, -1, &li);
if (index <> -1) {
lv1->EnsureVisible(index, true);
lv1->SetSel(index);
lv1->SetFocus();
}
thanx, seems my mistake was the -1 and the & ;)
lol how did you know my listview was named lv1 ;)
got it .. working great ;)
if anyone need it, here is a functiion:
you call it like that (if your listview is set as *lv1):
index = Finditem(lv1->m_hwnd,"your string");
return item position
return -1 if nothing found
//declare extern Finditem(unsigned int listview, String itemtext),int;
#define LVM_FIRST 0x1000
#define LVM_FINDITEM (LVM_FIRST + 13)
#define LVFI_STRING 0x0002
struct LVFINDINFO
{
unsigned int flags;
pointer *psz;
int lParam;
POINT pt;
unsigned int vkDirection;
}
global sub Finditem(unsigned int listview, String itemtext),int
{
LVFINDINFO li;
li.flags = LVFI_STRING;
li.psz = itemtext;
int index = SendMessage(listview, LVM_FINDITEM, -1, &li);
return index;
}