我已经查看了这个问题 - prevent listview to lose selected item。 但我需要这个代码用于VB.Net。我已经使用了c#到vb转换器,输出就是这个。
Private Sub ListView_SelectionChanged(sender As Object, e As SelectionChangedEventArgs)
Dim listView As ListView = TryCast(sender, ListView)
If listView.SelectedItems.Count = 0 Then
For Each item As Object In e.RemovedItems
listView.SelectedItems.Add(item)
Next
End If
End Sub
错误是:'SelectionChangedEventArgs' is not defined.
我将SelectionChangedEventArgs
替换为ByVal e As System.EventArgs
现在的错误是:
'RemovedItems' is not a member of 'System.EventArgs'.
Property: HideSelection = False
也不适合我。
我如何才能保持选定的行?