VB在ListView 中如何单击鼠标右键也能把该项选中

来源:百度知道 编辑:UC知道 时间:2024/06/05 11:07:46
如题!

Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim itm As ListItem
If Button = 2 Then
Set itm = ListView1.HitTest(x, y)
If Not itm Is Nothing Then Set ListView1.SelectedItem = itm
End If
End Sub

右击本来就选中了,不用任何代码
右击某项时,焦点也跟着去了,你屏蔽其右键菜单就行。