Hi,In my win32 application i have a list view control with grid view style ,i want to search items/SubItem on this List view control.I used ListView_FindItem macro,But it always returning 0 for both item as well as subitem.How to find out an item or subitem string from a list view control

Hi,In my win32 application i have a list view control with grid view style ,i want to search items/SubItem on this List view control.I used ListView_FindItem macro,But it always returning 0 for both item as well as subitem.How to find out an item or subitem string from a list view control

ListView_FindItem cannot search for sub-items, only for items.

ListView_FindItem returns the index of the item if successful, or -1 otherwise. So zero means the very first item was found.

Within the code block you are defining the variable lpfr. Where are you setting its contents before using it?:confused:

November 10th, 2013, 05:58 AM

Arjay

Re: Item search in Listview control

Another way to approach this is to use a virtual list backed by a std::list collection. The virtual list uses the collection to dyamically populate the items and subitems. You would then search the collection for the desired match, not the list control (which would effectively let you sesrch the data that makes up the subitems).

Isn't hWnd a dialog handle? Why do you use it rather than hWndListViewSymbol?

November 18th, 2013, 04:56 AM

manjut19

Re: Item search in Listview control

Quote:

Originally Posted by VictorN

Isn't hWnd a dialog handle? Why do you use it rather than hWndListViewSymbol?

Ya,i done mistake,I was written wrong.It should be hWndListViewSymbol.Thanks alot.But one more thing how to search subitems in a list view control,as like item saerching?

November 18th, 2013, 05:03 AM

VictorN

Re: Item search in Listview control

Quote:

Originally Posted by manjut19

... how to search subitems in a list view control,as like item saerching?

There is no any message nor API to search for a subitem.
You have to implement such a search yourself. For example get subitem text (ListView_GetItemText) in a loop and compare it with the pattern you need to look for.

November 18th, 2013, 05:12 AM

manjut19

Re: Item search in Listview control

Quote:

Originally Posted by VictorN

There is no any message nor API to search for a subitem.
You have to implement such a search yourself. For example get subitem text (ListView_GetItemText) in a loop and compare it with the pattern you need to look for.

Ok,Thanks alot I will try for that

November 18th, 2013, 05:47 AM

manjut19

Re: Item search in Listview control

One more qustuion,After Getting the index of searched item ,i have to make it as selected,But the same time previosly selected row should be deslected.How to deselect a perticular row?