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