'宣言 Public ReadOnly Property CurrentState As UltraListViewStates
public UltraListViewStates CurrentState {get;}
Imports Infragistics.Win Imports Infragistics.Win.UltraWinListView Private Sub ModifyHomeEndKeyMappings() ' The custom key mappings only apply to the iconic views, and multi-column list view If (Me.ultraListView1.CurrentState And UltraListViewStates.SupportsHorizontalItemNavigation) = UltraListViewStates.SupportsHorizontalItemNavigation Then ' Iterate the KeyActionMappings collection, and remove all mappings for ' the 'Home' and 'End' keys Dim keyMappings As UltraListViewKeyActionMappings = Me.ultraListView1.KeyActionMappings Dim keyMapping As UltraListViewKeyActionMapping = Nothing Dim i As Integer For i = keyMappings.Count - 1 To 0 Step -1 keyMapping = keyMappings(i) If (keyMapping.KeyCode = Keys.Home Or keyMapping.KeyCode = Keys.End) Then keyMappings.Remove(keyMapping) End If Next ' Add a new UltraListViewKeyActionMapping for the Home key which uses the ' 'ActivateFirstInIconRow' action, so that pressing the Home key navigates ' to the first item on the same row as the ActiveItem. keyMapping = New UltraListViewKeyActionMapping(Keys.Home, _ UltraListViewAction.ActivateFirstInIconRow, _ UltraListViewStates.ItemInEditMode, _ UltraListViewStates.SupportsHorizontalItemNavigation, _ SpecialKeys.All, _ 0) keyMappings.Add(keyMapping) ' Add a new UltraListViewKeyActionMapping for the End key which uses the ' 'ActivateLastInIconRow' action, so that pressing the End key navigates ' to the last item on the same row as the ActiveItem. keyMapping = New UltraListViewKeyActionMapping(Keys.End, _ UltraListViewAction.ActivateLastInIconRow, _ UltraListViewStates.ItemInEditMode, _ UltraListViewStates.SupportsHorizontalItemNavigation, _ SpecialKeys.All, _ 0) keyMappings.Add(keyMapping) ' Now add a new UltraListViewKeyActionMapping for the Home key which uses the ' 'ActivateFirst' action, and requires the Control key, so that pressing ' Ctrl+Home navigates to the first item displayed by the control. keyMapping = New UltraListViewKeyActionMapping(Keys.Home, _ UltraListViewAction.ActivateFirst, _ UltraListViewStates.ItemInEditMode, _ UltraListViewStates.SupportsHorizontalItemNavigation, _ 0, _ SpecialKeys.Ctrl) keyMappings.Add(keyMapping) ' Now add a new UltraListViewKeyActionMapping for the End key which uses the ' 'ActivateLast' action, and requires the Control key, so that pressing ' Ctrl+End navigates to the last item displayed by the control. keyMapping = New UltraListViewKeyActionMapping(Keys.End, _ UltraListViewAction.ActivateLast, _ UltraListViewStates.ItemInEditMode, _ UltraListViewStates.SupportsHorizontalItemNavigation, _ 0, _ SpecialKeys.Ctrl) keyMappings.Add(keyMapping) End If End Sub
using Infragistics.Win; using Infragistics.Win.UltraWinListView; using System.Diagnostics; private void ModifyHomeEndKeyMappings() { // The custom key mappings only apply to the iconic views, and multi-column list view if ( (this.ultraListView1.CurrentState & UltraListViewStates.SupportsHorizontalItemNavigation) == UltraListViewStates.SupportsHorizontalItemNavigation ) { // Iterate the KeyActionMappings collection, and remove all mappings for // the 'Home' and 'End' keys UltraListViewKeyActionMappings keyMappings = this.ultraListView1.KeyActionMappings; UltraListViewKeyActionMapping keyMapping = null; for ( int i = keyMappings.Count - 1; i >= 0; i-- ) { keyMapping = keyMappings[i]; if ( keyMapping.KeyCode == Keys.Home || keyMapping.KeyCode == Keys.End ) keyMappings.Remove( keyMapping ); } // Add a new UltraListViewKeyActionMapping for the Home key which uses the // 'ActivateFirstInIconRow' action, so that pressing the Home key navigates // to the first item on the same row as the ActiveItem. keyMapping = new UltraListViewKeyActionMapping( Keys.Home, UltraListViewAction.ActivateFirstInIconRow, UltraListViewStates.ItemInEditMode, UltraListViewStates.SupportsHorizontalItemNavigation, SpecialKeys.All, 0 ); keyMappings.Add( keyMapping ); // Add a new UltraListViewKeyActionMapping for the End key which uses the // 'ActivateLastInIconRow' action, so that pressing the End key navigates // to the last item on the same row as the ActiveItem. keyMapping = new UltraListViewKeyActionMapping( Keys.End, UltraListViewAction.ActivateLastInIconRow, UltraListViewStates.ItemInEditMode, UltraListViewStates.SupportsHorizontalItemNavigation, SpecialKeys.All, 0 ); keyMappings.Add( keyMapping ); // Now add a new UltraListViewKeyActionMapping for the Home key which uses the // 'ActivateFirst' action, and requires the Control key, so that pressing // Ctrl+Home navigates to the first item displayed by the control. keyMapping = new UltraListViewKeyActionMapping( Keys.Home, UltraListViewAction.ActivateFirst, UltraListViewStates.ItemInEditMode, UltraListViewStates.SupportsHorizontalItemNavigation, 0, SpecialKeys.Ctrl ); keyMappings.Add( keyMapping ); // Now add a new UltraListViewKeyActionMapping for the End key which uses the // 'ActivateLast' action, and requires the Control key, so that pressing // Ctrl+End navigates to the last item displayed by the control. keyMapping = new UltraListViewKeyActionMapping( Keys.End, UltraListViewAction.ActivateLast, UltraListViewStates.ItemInEditMode, UltraListViewStates.SupportsHorizontalItemNavigation, 0, SpecialKeys.Ctrl ); keyMappings.Add( keyMapping ); } }