Solved

Using FindItem to find a string in any column of CListCtrl

Posted on 2004-04-21
6
1,421 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

724 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