private void gridControl2_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
GridControl grid = sender as GridControl;
if (grid == null)
return;
int row = grid.CurrentCell.RowIndex;
int col = grid.CurrentCell.ColIndex;
switch (e.KeyCode)
{
case Keys.Up:
if (row > 1)
--row;
else
{
this.gridControl1.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.WhenGridActive;
this.gridControl2.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.HideAlways;
gridControl1.CurrentCell.MoveTo(gridControl1.RowCount, col, GridSetCurrentCellOptions.ScrollInView);
gridControl1.Focus();
}
break;
case Keys.Down:
if (row < grid.RowCount)
++row;
break;
case Keys.Left:
if (col > 1)
--col;
break;
case Keys.Right:
case Keys.Tab:
if (col < grid.ColCount)
++col;
break;
default: return;
} // switch
grid.CurrentCell.MoveTo(row, col, GridSetCurrentCellOptions.ScrollInView);
e.Handled = true;
}
private void gridControl1_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
GridControl grid = sender as GridControl;
if (grid == null)
return;
int row = grid.CurrentCell.RowIndex;
int col = grid.CurrentCell.ColIndex;
switch (e.KeyCode)
{
case Keys.Up:
if (row > 1)
--row;
break;
case Keys.Down:
if (row < grid.RowCount)
++row;
else
{
this.gridControl1.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.HideAlways;
this.gridControl2.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.WhenGridActive;
gridControl2.CurrentCell.MoveTo(1, col, GridSetCurrentCellOptions.ScrollInView);
gridControl2.Focus();
}
break;
case Keys.Left:
if (col > 1)
--col;
break;
case Keys.Right:
case Keys.Tab:
if (col < grid.ColCount)
++col;
break;
default: return;
} // switch
grid.CurrentCell.MoveTo(row, col, GridSetCurrentCellOptions.ScrollInView);
e.Handled = true;
}