'宣言 Public Property ActiveAppearance As Infragistics.Win.AppearanceBase
public Infragistics.Win.AppearanceBase ActiveAppearance {get; set;}
Imports Infragistics.Win Imports Infragistics.Win.UltraWinListView Private Sub InitializeVisualAppearance() ' Set the ImageTransparentColor property to Magenta, so ' that pixels of that color will be masked out of images Me.ultraListView1.ImageTransparentColor = Color.Magenta ' Use the ImageBackground property of the control's Appearance to display a watermark Me.ultraListView1.Appearance.ImageBackground = Image.FromFile("C:\watermark.bmp") Me.ultraListView1.Appearance.ImageBackgroundStyle = ImageBackgroundStyle.Centered ' Use the GroupAppearance to configure the visual appearance for all groups Me.ultraListView1.GroupAppearance.FontData.Name = "Tahoma" Me.ultraListView1.GroupAppearance.FontData.SizeInPoints = 12.0F Me.ultraListView1.GroupAppearance.TextHAlign = HAlign.Center ' Use a solid border note that this only applies when no OS themes are active Me.ultraListView1.BorderStyle = UIElementBorderStyle.Solid Me.ultraListView1.Appearance.BorderColor = Color.LightBlue ' Assign Color.LightBlue to the BackColor property of the ItemSettings' ActiveAppearance Me.ultraListView1.ItemSettings.ActiveAppearance.BackColor = Color.LightBlue ' Assign Color.Black to the ForeColor property of the ItemSettings' Appearance Me.ultraListView1.ItemSettings.Appearance.ForeColor = Color.Black ' Use a gradient to depict the HotTracking background Me.ultraListView1.ItemSettings.HotTrackingAppearance.BackColor2 = Color.LightBlue Me.ultraListView1.ItemSettings.HotTrackingAppearance.BackGradientStyle = GradientStyle.Vertical End Sub Private Sub ultraListView1_ItemActivating(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinListView.ItemActivatingEventArgs) Handles ultraListView1.ItemActivating Dim listView As UltraListView = CType(sender, UltraListView) Dim oldActiveItem As UltraListViewItem = listView.ActiveItem Dim newActiveItem As UltraListViewItem = e.Item ' If the item that is about to be activated belongs to ' a different group than the last active item, reset ' the last active group's appearance If Not oldActiveItem Is Nothing AndAlso _ Not oldActiveItem.Group Is Nothing AndAlso _ Not newActiveItem.Group Is Nothing AndAlso _ Not oldActiveItem.Group Is newActiveItem.Group Then oldActiveItem.Group.ResetAppearance() End If End Sub Private Sub ultraListView1_ItemActivated(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinListView.ItemActivatedEventArgs) Handles ultraListView1.ItemActivated ' Set the ForeColor of the new ActiveItem's Group's Appearance to red. If Not e.Item.Group Is Nothing Then e.Item.Group.Appearance.ForeColor = Color.Red End Sub
using Infragistics.Win; using Infragistics.Win.UltraWinListView; using System.Diagnostics; private void InitializeVisualAppearance() { // Set the ImageTransparentColor property to Magenta, so // that pixels of that color will be masked out of images this.ultraListView1.ImageTransparentColor = Color.Magenta; // Use the ImageBackground property of the control's Appearance to display a watermark this.ultraListView1.Appearance.ImageBackground = Image.FromFile( @"C:\watermark.bmp" ); this.ultraListView1.Appearance.ImageBackgroundStyle = ImageBackgroundStyle.Centered; // Use the GroupAppearance to configure the visual appearance for all groups this.ultraListView1.GroupAppearance.FontData.Name = "Tahoma"; this.ultraListView1.GroupAppearance.FontData.SizeInPoints = 12f; this.ultraListView1.GroupAppearance.TextHAlign = HAlign.Center; // Use a solid border; note that this only applies when no OS themes are active this.ultraListView1.BorderStyle = UIElementBorderStyle.Solid; this.ultraListView1.Appearance.BorderColor = Color.LightBlue; // Assign Color.LightBlue to the BackColor property of the ItemSettings' ActiveAppearance this.ultraListView1.ItemSettings.ActiveAppearance.BackColor = Color.LightBlue; // Assign Color.Black to the ForeColor property of the ItemSettings' Appearance this.ultraListView1.ItemSettings.Appearance.ForeColor = Color.Black; // Use a gradient to depict the HotTracking background this.ultraListView1.ItemSettings.HotTrackingAppearance.BackColor2 = Color.LightBlue; this.ultraListView1.ItemSettings.HotTrackingAppearance.BackGradientStyle = GradientStyle.Vertical; } private void ultraListView1_ItemActivated(object sender, Infragistics.Win.UltraWinListView.ItemActivatedEventArgs e) { // Set the ForeColor of the new ActiveItem's Group's Appearance to red. if ( e.Item.Group != null ) e.Item.Group.Appearance.ForeColor = Color.Red; } private void ultraListView1_ItemActivating(object sender, Infragistics.Win.UltraWinListView.ItemActivatingEventArgs e) { UltraListView listView = sender as UltraListView; UltraListViewItem oldActiveItem = listView.ActiveItem; UltraListViewItem newActiveItem = e.Item; // If the item that is about to be activated belongs to // a different group than the last active item, reset // the last active group's appearance if ( oldActiveItem != null && oldActiveItem.Group != null && newActiveItem.Group != null && oldActiveItem.Group != newActiveItem.Group ) oldActiveItem.Group.ResetAppearance(); }