How to navigate to the header cells using arrow keys in WinForms GridControl?
Navigate to header cells
You can handle the Grid control's keydown event and navigate to the header cells.
void gridControl1_KeyDown(object sender, KeyEventArgs e)
{
//get the current cell position
GridCurrentCell cc = this.gridControl1.CurrentCell;
Keys Keycodes = e.KeyCode & Keys.KeyCode;
switch (Keycodes)
{
//if left arrow pressed in the keyboard
case Keys.Left:
if (cc.ColIndex == 1)
{
cc.MoveTo(cc.RowIndex, 0);
}
break;
//if up arrow pressed in the keyboard
case Keys.Up:
if (cc.RowIndex == 1)
{
cc.MoveTo(0, cc.ColIndex);
}
break;
}
}Private Sub gridControl1_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
'get the current cell position
Dim cc As GridCurrentCell = Me.gridControl1.CurrentCell
Dim Keycodes As Keys = e.KeyCode And Keys.KeyCode
Select Case Keycodes
'if left arrow pressed in the keyboard
Case Keys.Left
If cc.ColIndex = 1 Then
cc.MoveTo(cc.RowIndex, 0)
End If
'if up arrow pressed in the keyboard
Case Keys.Up
If cc.RowIndex = 1 Then
cc.MoveTo(0, cc.ColIndex)
End If
End Select
End Sub Samples: