Listview question

  • Thread starter Thread starter Jan
  • Start date Start date
J

Jan

How do i get the index of a selected item from a listview, I know how it
works for a listbox. But I can't figure it out for a listview?

Another newbee question

By the way, thx for the answers I allready got on my other newbee
questions. You guys must have a lot of petians with me.
Thx a lot
 
* Jan said:
How do i get the index of a selected item from a listview, I know how it
works for a listbox. But I can't figure it out for a listview?

Another newbee question

By the way, thx for the answers I allready got on my other newbee
questions. You guys must have a lot of petians with me.

Loop thorugh the ListView's 'SelectedIndices' collection, get the
according items and compare them to your item.
 
When you say index from the item. Do you mean the row index in the ListView
or are you referring to a bound data object ?

Regards - OHM
How do i get the index of a selected item from a listview, I know how
it works for a listbox. But I can't figure it out for a listview?

Another newbee question

By the way, thx for the answers I allready got on my other newbee
questions. You guys must have a lot of petians with me.
Thx a lot

Best Regards - OHMBest Regards - OHM (e-mail address removed)
 
When you say index from the item. Do you mean the row index in the ListView
or are you referring to a bound data object ?

Regards - OHM


Best Regards - OHMBest Regards - OHM (e-mail address removed)

I mean the row index, I select the the complete row (fullRowSelect)
 
Use the ListViewItem.FocusedItem.Index method. Example below.

Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged

Dim lvi As ListViewItem

Dim lv As ListView

lv = DirectCast(sender, ListView)

lvi = lv.FocusedItem

Debug.WriteLine(lvi.Index.ToString())

End Sub

Regards - OHM

(e-mail address removed)

I mean the row index, I select the the complete row (fullRowSelect)

Best Regards - OHMBest Regards - OHM
 
Back
Top