Hi,

I have a listbox that is connected to a text file and this file is created when the program opens for the first time and then users can add data to the file as they wish. However what I am having a problem with is that how can I link the selected item in the listview to a textbox.

I.e.

Listview has 3 columns: Name, Surname and Location

Then when the line is selected i want the 3 individual variables to display in 3 seperate text boxes that has been set up.

Any help would be greatly appreciated.

Perfect. Had to change it a little to work with the following code:

Private Sub ListViewSelection()

        If lvLocations.SelectedItems.Count > 0 Then
            Dim list As ListViewItem = lvLocations.SelectedItems(0)
            'Check whether subitems exists
            If list.SubItems.Count >= 1 Then
                'Here also check whether they are empty
                If list.SubItems(1).Text <> "" Then
                    'MsgBox(list.Text & " " & list.SubItems(1).Text)
                    'tbTest.Text = list.Text & " " & list.SubItems(1).Text
                    tbPNID.Text = list.Text
                    tbDID.Text = list.SubItems(1).Text
                    tbDPID.Text = list.SubItems(2).Text
                Else
                    MsgBox("Incomplete")
                End If
            Else
                MsgBox("Incomplete")
            End If
        End If

    End Sub
This article has been dead for over six months. Start a new discussion instead.