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

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

Jack
Sun Jul 20 10:43:33 PDT 2008

Sorry, wrong forum.
Jack
"Jack" <replyto@it> wrote in message
news:%23vl%234oo6IHA.3480@TK2MSFTNGP03.phx.gbl...
> 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
>
>