Imports Infragistics.Win Private Sub SetKeyMappings() ' Maps the W and Z keys to traverse the grid up and down when not in edit mode. MapKey(Keys.Z, UltraWinGrid.UltraGridAction.NextRow) MapKey(Keys.W, UltraWinGrid.UltraGridAction.PrevRow) End Sub Private Sub MapKey(ByVal key As System.Windows.Forms.Keys, ByVal action As UltraWinGrid.UltraGridAction) If Me.UltraGrid1.KeyActionMappings.IsKeyMapped(key, 0) Then ' Remove the existing mapping if it exists Dim i As Integer For i = 0 To Me.UltraGrid1.KeyActionMappings.Count - 1 If Me.UltraGrid1.KeyActionMappings(i).KeyCode = key Then Me.UltraGrid1.KeyActionMappings.Remove(i) End If Next i Dim ka As UltraWinGrid.GridKeyActionMapping = New UltraWinGrid.GridKeyActionMapping(key, action, UltraWinGrid.UltraGridState.InEdit, 0, 0, 0) Me.UltraGrid1.KeyActionMappings.Add(ka) Else Dim ka As UltraWinGrid.GridKeyActionMapping = New UltraWinGrid.GridKeyActionMapping(key, action, UltraWinGrid.UltraGridState.InEdit, 0, 0, 0) Me.UltraGrid1.KeyActionMappings.Add(ka) End If End Sub
using Ingragistics.Win; private void SetKeyMappings() { // Maps the W and Z keys to traverse the grid up and down when not in edit mode. MapKey(Keys.Z, UltraWinGrid.UltraGridAction.NextRow); MapKey(Keys.W, UltraWinGrid.UltraGridAction.PrevRow ); } private void MapKey(System.Windows.Forms.Keys key, UltraWinGrid.UltraGridAction action) { if (this.ultraGrid1.KeyActionMappings.IsKeyMapped(key,0)) { // Remove the existing mapping if it exists for(int i = 0; i < this.ultraGrid1.KeyActionMappings.Count; i++) { if (this.ultraGrid1.KeyActionMappings[i].KeyCode == key ) { this.ultraGrid1.KeyActionMappings.Remove(i); break; } } UltraWinGrid.GridKeyActionMapping ka = new UltraWinGrid.GridKeyActionMapping(key,action,UltraWinGrid.UltraGridState.InEdit ,0,0,0); this.ultraGrid1.KeyActionMappings.Add(ka); } else { UltraWinGrid.GridKeyActionMapping ka = new UltraWinGrid.GridKeyActionMapping(key,action,UltraWinGrid.UltraGridState.InEdit ,0,0,0); this.ultraGrid1.KeyActionMappings.Add(ka); } }