i am having a little trouble with listview control. how can i check if the cursor was not clicked on an icon. i want to know if the user is clicking on the cursor or on the empty area.
Printable View
i am having a little trouble with listview control. how can i check if the cursor was not clicked on an icon. i want to know if the user is clicking on the cursor or on the empty area.
You can do something like this. Use the MouseDown event of the ListView to check if the user has selected anything in a ListView:
Regards,Code:Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim itmListItem As ListItem
Set itmListItem = ListView1.HitTest(x, y)
If itmListItem Is Nothing Then
MsgBox "Nothing is selected."
Else
MsgBox "You selected " & itmListItem.Text
End If
End Sub
you suggestion works fine with single click, but when a user selects an item, and then double clicks on the listview control's blank area, the item which was selected the last time receives the focus. what i want is that when the user selects an item, and if he double clicks outside an item, the item should lose the focus just like in windows explorer.
i hope you get what i mean.
You can try something like this:
Code:Option Explicit
Private itmListItem As ListItem
Private Sub ListView1_DblClick()
If itmListItem Is Nothing Then
MsgBox "Nothing is selected."
Else
MsgBox "You selected " & itmListItem.Text
End If
End Sub
Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Set itmListItem = ListView1.HitTest(x, y)
End Sub
but the item still doesnt loose the focus, it receives the focus again after double click, i want it to work like windows explorer.
can anyone help,.....anyone???