ListView1.SelectedItems(0) does not work in compact framework - Is there an alternative?

T

Tim Burr

I am trying to make it so when a user clicks on an item in a listview
that 3 textboxes are populated.

Here is what I have so far:

Private Sub ListView1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ListView1.SelectedIndexChanged
If ListView1.SelectedIndices.Count > 0 Then
Dim lvi As ListViewItem = ListView1.SelectedItems(0)
TextBox1.Text = lvi.Text
TextBox2.Text = lvi.SubItems(1).Text
TextBox3.Text = lvi.SubItems(2).Text
End If
End Sub

I get an error as follows:

'SelectedItems' is not a member of 'System.Windows.Forms.ListView'.

Is there another way to do this?

Thanks

TB
 
T

Tim Wilson

You can use the "SelectedIndices" property. Something like this...

ListView1.Items(ListView1.SelectedIndices(0))
 

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