istview1 选定索引= listview2 选定索引
如果我在 listview1 中选择一个项目,那么 listviews2 的索引将与 listview1 相同。我该怎么做?请帮帮我。
Private Sub ListView1_SelectedIndexChanged (ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
'// Loop through in case MultiSelect is on
For i as Integer = 0 to ListView1.Items.Count - 1
ListView2.Items(i).Selected = ListView1.Items(i).Selected
Next i
'// or if multiselect is not on... changing index will uncheck everything else
Try
ListView2.Items(ListView1.SelectedIndices(0)).Selected = True
Catch ex as Exception '// catch means nothing was selcted in first list
If ListView2.SelectedItems.Count > 0 then '// clear if necessary
ListView2.SelectedItems(0).Selected = False
End if
End Try
End Sub