Hi,

I am having trouble with a command and tried everything but cant get it to work.

I have a detailed list view which reads a text file and populates the contol. So when I select a line it populates 3x text boxes with the values. (there are 3 columns in the listview)

But what I want to do is when a user clicks on a row it populates it with text in the text boxes (which works fine) but then when the user click on a section without any data then nothing should be in the text boxes.

Here is my code:

Code:
Public Sub ListViewSelection()

        Dim list As ListViewItem = lvLocations.SelectedItems(0)

        If lvLocations.SelectedItems.Count > 0 Then

            If list.SubItems.Count >= 1 Then

                If list.SubItems(1).Text <> "" Then

                    tbLineNo.Text = list.Index.ToString
                    tbID1.Text = list.Text
                    tbID2.Text = list.SubItems(1).Text
                    tbDPID.Text = list.SubItems(2).Text

                ElseIf list.SubItems(1).Text = "" Then

                    tbLineNo.Clear()
                    tbID1.Clear()
                    tbID2.Clear()
                    tbDPID.Clear()

                End If

            ElseIf list.SubItems.Count < 1 Then

                tbLineNo.Clear()
                tbID1.Clear()
                tbID2.Clear()
                tbDPID.Clear()

            End If

        ElseIf lvLocations.SelectedItems.Count <= 0 Then

            tbLineNo.Clear()
            tbID1.Clear()
            tbID2.Clear()
            tbDPID.Clear()

        End If

    End Sub