Solved

Using FindItem to find a string in any column of CListCtrl

Posted on 2004-04-21
6
1,379 Views
Last Modified: 2013-12-03
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.
0
Comment
Question by:mromeo
  • 3
6 Comments
 
LVL 8

Expert Comment

by:_corey_
ID: 10882754
No, you just need to use the LVFINDINFO structure and tell it to search for a string, or partial and string if you want stuff like beginning matches.

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->FindItem(&info)) != -1)
{
   pmyListCtrl->DeleteItem(nIndex);
}
0
 

Author Comment

by:mromeo
ID: 10882794
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?
0
 
LVL 8

Accepted Solution

by:
_corey_ earned 125 total points
ID: 10882958
Well, only thing I can think off of the top of my head is using the LVFI_NEARESTXY flag, and setting virtual keycode to VK_RIGHT.  If that only does the row, then loop through every row.
0
 
LVL 8

Expert Comment

by:_corey_
ID: 10882965
I do not know what VK_HOME would do.  Or VK_NEXT.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now