My App edits data on a listview, by clicking on a row then clicking the edit button btnEdit.

Dim PrimaryKey as String
    Private Sub ListView1_MouseDoubleClicklstSearch.MouseClick
        With .SelectedItems(0)
             PrimaryKey = .SubItems(0).Text
        End With
    End Sub
    Private Sub btnEdit_Click
        If ListView1.SelectedItems.Count > 0 Then
               ' Show dialog box
        Else
               MsgBox("Select First")
        End If
    End Sub

Edit dialog shows when "Edit" button is click, to make sure there is a selected item to modify I used ListView1.SelectedItems.Count.

Problem is that when I select on a row and disselect it, the SelectedItems.Count is still 1.

Nevermind, it seems that even if I focused on something else like a textbox or clicking a button. The selected row does not lose its focus, even if the selection color(blue by default) on the row is gone.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.