mromeo
asked on
Using FindItem to find a string in any column of CListCtrl
I have a CListCtrl with three columns. I want to use the FindItem method to find a string in any of the 3 columns of the ctrl. It looksl iike I'm supposed to use the lParam field of the LVFINDINFO struct, but it's not obvious to me how to use this technique. Anybody have any ideas?
Thanks.
Thanks.
ASKER
This only searches on the first column in the list control. I have 3 columns and I want to be able to search for text in all 3 of them. Is this possible?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I do not know what VK_HOME would do. Or VK_NEXT.
In this example replace the line:
info.psz = lpszmyString
with your string assignment. The string you want to search for.
-- Taken from Microsoft examples for consistancy.
// The pointer to my list view control.
extern CListCtrl* pmyListCtrl;
// The string to match.
extern LPCTSTR lpszmyString;
LVFINDINFO info;
int nIndex;
info.flags = LVFI_PARTIAL|LVFI_STRING;
info.psz = lpszmyString;
// Delete all of the items that begin with the string lpszmyString.
while ((nIndex=pmyListCtrl->Find
{
pmyListCtrl->DeleteItem(nI
}