'Declaration Public Property SelectedAppearance As Infragistics.Win.AppearanceBase
public Infragistics.Win.AppearanceBase SelectedAppearance {get; set;}
The UltraListViewItem and UltraListViewSubItem classes each expose an Appearance property, which determines the visual appearance for that particular item or sub-item.
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
using Infragistics.Win; using Infragistics.Win.UltraWinListView; using System.Diagnostics; private void ultraListView1_ItemSelectionChanging(object sender, Infragistics.Win.UltraWinListView.ItemSelectionChangingEventArgs e) { // Get a reference to the UltraListView control UltraListView listView = sender as 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 UltraListViewItem previousSelectedItem = 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 && previousSelectedItem != null ) { foreach( UltraListViewItem 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 ( selectedItem.Group != previousSelectedItem.Group && e.SelectedItems.First != e.SelectedItems.Last ) { e.Cancel = true; break; } } } } private void ultraListView1_ItemSelectionChanged(object sender, Infragistics.Win.UltraWinListView.ItemSelectionChangedEventArgs e) { // Get a reference to the UltraListView control UltraListView listView = sender as UltraListView; // Apply a different appearance based on whether multiple items are selected if ( e.SelectedItems.Count > 1 ) { listView.ItemSettings.SelectedAppearance.BackColor = Color.LightBlue; listView.ItemSettings.SelectedAppearance.BackColor2 = SystemColors.Highlight; listView.ItemSettings.SelectedAppearance.BackGradientStyle = GradientStyle.Vertical; } else listView.ItemSettings.SelectedAppearance.Reset(); }
Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2