Solved

Listview control--searching subitems

Posted on 1998-11-11
5
467 Views
Last Modified: 2013-11-20
I've got a listview control with several columns. I am using CListCtrl::FindItem to search.  It finds matches when i'm searching for data in the first column of the listcontrol, but not when i'm searching for data that exists in any other column.  How do I search other columns?
0
Comment
Question by:jerryross
[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
  • 2
  • 2
5 Comments
 

Author Comment

by:jerryross
ID: 1324529
I figured it out...here is the code if you're curious:
 
  // declare variables
  int nIndexStart;
  LV_FINDINFO lvfi={0};
  ::ZeroMemory (&lvfi, sizeof (LV_FINDINFO));

  LV_ITEM dwItemData;  //stucture to hold item search data
  LV_ITEM *pdwItemData; // point to item search data
  dwItemData.mask = LVIF_TEXT; // to search for text
  dwItemData.iSubItem = 2;  // to search subitem column 2
  dwItemData.pszText = "Looking for this text"
             
  lvfi.flags = LVFI_PARAM; // to tell it to look at the item structure
  lvfi.lParam = (LPARAM) pdwItemData; // point at item structure

  nIndexStart = DefWindowProc(LVM_FINDITEM, (WPARAM)-1, (LPARAM)&lvfi);  //do search and return the index of the match

My question now is this:  How does it know which listview control i'm asking it to search?  The code works though so i'm happy :)

0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 50 total points
ID: 1324530
LVM_FINDITEM is a message, use SendMessage to send it to a particular window

It knows with your code because it's DefWindowProc is a member of CWnd (base class of CListCtrl) and what you are really doing is :-

this->DefWindowProc(LVM_FINDITEM, (WPARAM)-1, (LPARAM)&lvfi);

0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1324531
The this-> is implicit

If you want to specify a particular window to call a member function for use

pWnd->_whatever__
( for CWnd * and pointers to derived classes of CWnd)
or

wnd.__whatever__
( for actual CWnd objects, and derived classes of CWnd)
0
 

Author Comment

by:jerryross
ID: 1324532
Thank you ~!~
0
 

Expert Comment

by:geo_134
ID: 3930980
i need to find a item in particuar row
and highlight that particular row.i am have 1000 rows and 10 columns.i have used rowlist sample from msdn help.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

628 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