Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ListView项目激活延迟_C#_.net_Vb.net_Listview - Fatal编程技术网

C# ListView项目激活延迟

C# ListView项目激活延迟,c#,.net,vb.net,listview,C#,.net,Vb.net,Listview,我有一个带有热跟踪的激活属性的ListView。从用户单击项目到触发事件之间似乎有大约2秒的延迟。是否有办法在用户单击时立即触发事件?是,请改用SelectedIndexChanged事件 是,请改用SelectedIndexChanged事件 我没有办法改变这个延迟,这是一个内置设置 问题是,MouseDown事件实际上有一个延迟反应,只在它触发后设置SelectedItems属性 您必须手动执行此操作:使用MouseClick事件。如果单击某个项目,即使该项目是已选择的项目,也会触发此操作。

我有一个带有热跟踪的激活属性的ListView。从用户单击项目到触发事件之间似乎有大约2秒的延迟。是否有办法在用户单击时立即触发事件?

是,请改用SelectedIndexChanged事件

是,请改用SelectedIndexChanged事件

我没有办法改变这个延迟,这是一个内置设置

问题是,MouseDown事件实际上有一个延迟反应,只在它触发后设置SelectedItems属性

您必须手动执行此操作:使用MouseClick事件。如果单击某个项目,即使该项目是已选择的项目,也会触发此操作。单击空白区域时,它不会激发

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
您可以通过处理此事件来模拟热跟踪

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

我没有办法改变这个延迟,这是一个内置设置

问题是,MouseDown事件实际上有一个延迟反应,只在它触发后设置SelectedItems属性

您必须手动执行此操作:使用MouseClick事件。如果单击某个项目,即使该项目是已选择的项目,也会触发此操作。单击空白区域时,它不会激发

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
您可以通过处理此事件来模拟热跟踪

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

考虑到这一点,但是如果项目已经被选中,它将不起作用。考虑到这一点,但是如果项目已经被选中,它将不起作用。