ListView

  • Thread starter Thread starter Bikesh Lakhmichand
  • Start date Start date
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
 
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 ?
 
* "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?
 
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 ?
 
Back
Top