Imports Infragistics.Win
Imports Infragistics.Win.UltraWinListView
Private Sub ultraListView1_ItemSelectionChanging(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinListView.ItemSelectionChangingEventArgs) Handles ultraListView1.ItemSelectionChanging
' Get a reference to the UltraListView control
Dim listView As UltraListView = CType(sender, UltraListView)
' Get a reference to the last member of the SelectedItems
' collection...note that it does not matter which member we use,
' we just need any currently selected item
Dim previousSelectedItem As UltraListViewItem = listView.SelectedItems.Last
' Iterate the SelectedItems collection passed through the
' event arguments this represents what the contents of the
' UltraListView's SelectedItems collection will become if this
' event is not canceled.
If listView.ShowGroups AndAlso Not previousSelectedItem Is Nothing Then
Dim selectedItem As UltraListViewItem
For Each selectedItem In e.SelectedItems
' If any member of the new SelectedItems collection is
' in a different group than the currently selected items,
' cancel the event.
If Not selectedItem.Group Is previousSelectedItem.Group AndAlso _
Not e.SelectedItems.First Is e.SelectedItems.Last Then
e.Cancel = True
Return
End If
Next
End If
End Sub
Private Sub ultraListView1_ItemSelectionChanged(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinListView.ItemSelectionChangedEventArgs) Handles ultraListView1.ItemSelectionChanged
' Get a reference to the UltraListView control
Dim listView As UltraListView = CType(sender, UltraListView)
' Apply a different appearance based on whether multiple items are selected
If (e.SelectedItems.Count > 1) Then
listView.ItemSettings.SelectedAppearance.BackColor = Color.LightBlue
listView.ItemSettings.SelectedAppearance.BackColor2 = SystemColors.Highlight
listView.ItemSettings.SelectedAppearance.BackGradientStyle = GradientStyle.Vertical
Else
listView.ItemSettings.SelectedAppearance.Reset()
End If
End Sub