Solved

Using FindItem to find a string in any column of CListCtrl

Posted on 2004-04-21
6
1,391 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Method 'OpenReport' of the object Docmd failed 7 28
dialer.exe 4 58
Is AWS.RDS considered a part of "Big Data"? 4 94
String manipulation in Visual Basic 7 59
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 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

24 Experts available now in Live!

Get 1:1 Help Now