Replies To: Problem transferring listview column 2 items to textbox

Re: Problem transferring listview column 2 items to textbox

Posted 14 January 2013 - 09:33 PM

(FOR THIS U NEED THE TEXTBOX AS MANY AS U HAVE COLUMNS) FOR EXAMPLE IF U WANT TO COPY DATA FROM 4 COLUMNS U NEED 4 TEXTBOX.

HERE I HAVE TAKEN 3.

Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
' Copy the data from the listview into the textboxes
' If you only have a few columns then this will be OK:
Try
With ListView1
' Check that a selection has been made/remade
If .SelectedIndices.Count > 0 Then
TextBox1.Text = .Items(.SelectedIndices(0)).Text
TextBox2.Text = .Items(.SelectedIndices(0)).SubItems(1).Text
TextBox3.Text = .Items(.SelectedIndices(0)).SubItems(2).Text
End If
End With
Catch ex As Exception
End Try
End Sub