ListView

B

Bikesh Lakhmichand

How does one find an item within a listview by just the text property of an
item ? I know im suppose to pass a ListViewItem to the IndexOf method but
what do i set to the ListViewItem object ? Just the text value of the item
im searching ?

i.e

ls = New ListViewItem("string to search")
dim intPosition as integer= ListView1.Items.IndexOf(ls)

that dont seem to work..

so i decided to make my ls variable form level thats used during the
population of the listview itself
 
B

Bikesh Lakhmichand

oops..incompleted last post...
did a form level of listviewitem and had it populate the listview with this

While reader.Read
ls = New ListViewItem(reader.Item("customerid").ToString())
ls.SubItems.Add(reader.Item("orderID").ToString())
ls.SubItems.Add(reader.Item("employeeid").ToString())
LVitems.Items.Add(ls)
End While

so now im my find routine im just trying to set the ls with new text
properties for the indexOf method.. i only end up with the last index number
instead of -1 this time.. any input ? vb6 had the finditem method but MS
says use IndexOf.. anyone ?
 
H

Herfried K. Wagner [MVP]

* "Bikesh Lakhmichand said:
How does one find an item within a listview by just the text property of an
item ? I know im suppose to pass a ListViewItem to the IndexOf method but
what do i set to the ListViewItem object ? Just the text value of the item
im searching ?

Did you notice that the text sometimes isn't unique?
 
M

Mike Smith

well assuming of course that this particular columns text property is a
unique field value. How is it done then ? can one use the old sendmessage
api to get the index ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top