Solved

Find items in ListView

Posted on 2004-04-11
3
382 Views
Last Modified: 2008-02-01
Hi,

Can anyone please let me know how to search listview items in vb.net. I have a listview whose items are populated with strings. I need to compare the listview items with strings. For every match, I need to get the index of the listview item and select it.

Thanks in advance,
Pratibha

0
Comment
Question by:pratibharao
3 Comments
 
LVL 19

Accepted Solution

by:
Desp earned 75 total points
ID: 10803709
Dim lv As ListViewItem
For Each lv In ListView1.Items
            If lv.Text = "MatchingString" Then
                lv.Selected = True
                ' MsgBox(lv.Index) 'at the end of this loop the ListView1.SelectedIndices will contain all the selected rows in LV
            End If
Next
0
 

Expert Comment

by:kantrishi
ID: 11126025
By putting above mentioned code, we have to pass exact matching string to find, i would like to know is there any method so that we can send partial string so that we could find number of row for partial match

Thanks and regards,

Rishi Kant
0
 
LVL 27

Expert Comment

by:Dabas
ID: 13178314
Hi pratibharao:
This might be of help:

http://www.codeproject.com/useritems/LVFind.asp

Dabas
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

821 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