ListView ItemActivate Delay

I have a ListView with an Activation property with HotTracking. There seems to be about a 2 second delay between when the user clicks on the element and the event fires. Is there a way to fire the event immediately after the user clicks?

+1


a source to share


2 answers


I haven't found a way to change this delay, it's a built-in setting.

The problem is that the MouseDown event actually has a delayed response, setting only the SelectedItems property after .

You need to do it manually: use the MouseClick event. This fires if the item is clicked, even if it is already selected. It won't fire when empty space is clicked.



Private Sub list_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles list.MouseClick
    Dim item As ListViewItem = list.GetItemAt(e.X, e.Y)
    If Not IsNothing(item) Then
        do your stuff here
    End If
End Sub

      

You can simulate hot tracking by handling this event

Private Sub list_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles list.MouseMove
    Dim item As ListViewItem = list.GetItemAt(e.X, e.Y)
    If Not IsNothing(item) Then
        list.SelectedItems.Clear()
        item.Selected = True
    End If
End Sub

      

+4


a source


Yes, use the SelectedIndexChanged event instead!



0


a source







All Articles