如何在 VB.net 中突出显示事件中的Listview
项目MouseHover
,就像 Windows 资源管理器一样?
问问题
4467 次
2 回答
2
将控件的HoverSelection
属性设置为. 但是,如果您希望它立即被选中,您可以手动实现它。例如,您可以尝试这样的事情:ListView
True
Private Sub ListView1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseMove
Dim currentItem As ListViewItem = ListView1.GetItemAt(e.X, e.Y)
For Each item As ListViewItem In ListView1.Items
item.Selected = False
Next
If currentItem IsNot Nothing Then
currentItem.Selected = True
End If
End Sub
但是,请确保控件HideSelection
上的属性ListView
设置为False
,否则除非列表具有焦点,否则不会显示选择。
于 2012-10-02T15:24:49.037 回答
0
不闪烁:
Private Sub ListView1_MouseMove(sender As Object, e As MouseEventArgs) Handles ListView1.MouseMove
Dim currentItem As ListViewItem = ListView1.GetItemAt(e.X, e.Y)
For Each item As ListViewItem In ListView1.Items
If currentItem IsNot Nothing Then
currentItem.Selected = True
Else
item.Selected = False
End If
Next
End Sub
于 2018-12-03T13:44:13.823 回答