1、有表头,无数据(也就是数据是0件)的情况,需要增加以下代码。
private void fpSpread1_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Tab)
{
if (fpSpread1.ActiveSheet.ActiveRowIndex == fpSpread1.ActiveSheet.RowCount - 1 &&
fpSpread1.ActiveSheet.ActiveColumnIndex == -1)
{
Control p;
p = ((FarPoint.Win.Spread.FpSpread)sender).Parent;
p.SelectNextControl(ActiveControl, true, true, true, true);
}
}
else if (e.KeyData == (Keys.Tab | Keys.Shift))
{
if (fpSpread1.ActiveSheet.ActiveRowIndex == fpSpread1.ActiveSheet.RowCount - 1 &&
fpSpread1.ActiveSheet.ActiveColumnIndex == -1)
{
Control p;
p = ((FarPoint.Win.Spread.FpSpread)sender).Parent;
p.SelectNextControl(ActiveControl, false, true, true, true);
}
}
}
2、有表头,有数据。(需要增加输入映射)
第一种方法:(画面实现)
通过打开 Spread设计器 -> 设置 -> 输入映射(此时会打开 输入映射编辑器),将 tab和shift tab 的映射进行增加。
tab:MoveToNextCellThenControl
shift + tab:MoveToPreviousCellThenControl
第二种方法:(代码实现)
InputMap im = this.GetInputMap(InputMapMode.WhenFocused);
im.Put(new Keystroke(Keys.Tab, Keys.None), SpreadActions.MoveToNextCellThenControl);
im.Put(new Keystroke(Keys.Tab, Keys.Shift), SpreadActions.MoveToPreviousCellThenControl);