保持选中的列表视图行

时间:2014-02-15 15:34:26

标签: vb.net visual-studio-2008

我已经查看了这个问题 - 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也不适合我。

我如何才能保持选定的行?

0 个答案:

没有答案