How to unselect listview row when i click on white area of listview under rows?
Hi all. could any one show me how i can detect if user clicked(left and write) on white area of listview as shown in the pic. When i say white area i mean area where there is no row in listview . I want to detect click on that white area and be able to unselect row.
Last edited by tony88; May 14th, 2007 at 04:39 PM.
Re: How to unselect listview row when i click on white area of listview under rows?
Code:
Private Sub ListView1_Click()
Debug.Print (ListView1.SelectedItem Is Nothing)
End Sub
Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbLeftButton Then
If ListView1.HitTest(x, y) Is Nothing Then
Set ListView1.SelectedItem = Nothing
End If
End If
End Sub
With best wishes, Vita
-----------------------
Russian Software Development Network -- http://www.rsdn.ru
Re: How to unselect listview row when i click on white area of listview under rows?
Originally Posted by Vi2
Code:
Private Sub ListView1_Click()
Debug.Print (ListView1.SelectedItem Is Nothing)
End Sub
Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbLeftButton Then
If ListView1.HitTest(x, y) Is Nothing Then
Set ListView1.SelectedItem = Nothing
End If
End If
End Sub
v1 thanks. But could you tell me how to add it to my existing mousdown event. I posted it here:
Code:
Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim lvwItem As ListItem
If Button = vbRightButton Then
Set lvwItem = ListView1.HitTest(x, y)
If Not lvwItem Is Nothing Then
Frame1.Visible = True
lvwItem.Selected = True
PopupMenu mnuEdit
Else
Frame1.Visible = False
End If
End If
End Sub
I placed you code at the end of my above code and it keep giving this error:
Re: How to unselect listview row when i click on white area of listview under rows?
Maybe this code helps:
Code:
Private Sub ListView1_Click()
If Not ListView1.SelectedItem Is Nothing Then
gstrSomething = ListView1.SelectedItem.SubItems(4)
gstrSomethingElse = ListView1.SelectedItem.Text
Frame1.Visible = True
'Frame1.Refresh
WebBrowser1.Refresh
WebBrowser2.Refresh
End If
End Sub
With best wishes, Vita
-----------------------
Russian Software Development Network -- http://www.rsdn.ru
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.