确定列表视图的索引是否由鼠标或键盘触发

时间:2015-02-11 05:25:41

标签: vb.net winforms listview

如何确定列表视图的索引是否已使用鼠标或键盘触发?

确定选定的索引已更改事件,我使用此

Private Sub lv_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lv.SelectedIndexChanged

End Sub

是否只有鼠标点击的事件?或任何检测是否由鼠标点击或键盘触发的条件?请帮忙

1 个答案:

答案 0 :(得分:0)

我相信您可以检查发件人(ListView)的MouseButtons属性,以确定用户是否按下任何鼠标按钮:

Private Sub lv_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lv.SelectedIndexChanged
    If sender.MouseButtons = MouseButtons.None Then
        ' No buttons being pressed (keyboard used)
    Else
        ' Mouse button being pressed
    End If
End Sub