How can i get the index of a listview

J

Jan

Hello everybody.

Can someone tell me how i can get the index of an listview.
I tried it at th e following way:

public intIndexListview As ListView.SelectedIndexCollection

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

intIndexListview = ListView1.SelectedIndices.Index ( i get an error on this
line)
TextBox2.Text = intIndexListview

end sub

newbee question i know

thanks for your help ia
 
H

Herfried K. Wagner [MVP]

Jan said:
Can someone tell me how i can get the index of an listview.
I tried it at th e following way:

public intIndexListview As ListView.SelectedIndexCollection

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

intIndexListview = ListView1.SelectedIndices.Index ( i get an error on
this
line)

In your 'SelectedIndexChanged' event handler:

\\\
Dim SourceControl As ListView = DirectCast(sender, ListView)
If SourceControl.SelectedIndices.Length > 0 Then
Dim IndexListView As Integer = SourceControl.SelectedIndices.Length
...
End If
///
 

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