Spread for WinForms是通过 InputMap 来控制键盘操作,通过以下代码可以实现ComboBox编辑状态下,按Enter键之后跳转到下一个单元格:
- private void Form1_Load(object sender, EventArgs e)
- {
- fpSpread1.ActiveSheet.RowCount = 10;
- fpSpread1.ActiveSheet.ColumnCount = 5;
- FarPoint.Win.Spread.CellType.ComboBoxCellType cbct = new FarPoint.Win.Spread.CellType.ComboBoxCellType();
- cbct.Editable = true;
- cbct.Items = new string[] { "AA","BB","CC"};
- fpSpread1.ActiveSheet.Columns[0].CellType = cbct;
- FarPoint.Win.Spread.InputMap im = new FarPoint.Win.Spread.InputMap();
- im = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused);
- im.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextColumnWrap);
- im = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused);
- im.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.MoveToNextColumnWrap);
- }
复制代码 |