ListView: how to detect if the item is selected with the first mouse click?

J

Jack

Hello,
When the item is selected I need to enable cmdDelete btn.
and if there is not item selected cmdDelete btn must be disabled.
The problem with the code I use (see below) is that when user change the
selected item (or when user select item for the first time) the code below
does not "see" selected item with the first mouse click.

Private Sub lvSelLines_MouseDown(Button As Integer, Shift As Integer, x As
Single, y As Single)
For i = lvSelLines.ListItems.Count To 1 Step -1
If lvSelLines.ListItems(i).Selected = True Then
cmdDelete.Enabled = True
Exit Sub
End If
Next
cmdDelete.Enabled = False
End Sub

How to correct that?
Jack
 

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