?
Solved

Using FindItem to find a string in any column of CListCtrl

Posted on 2004-04-21
6
Medium Priority
?
1,439 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 500 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

801 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