回车对于combo 就是展开选择,如果您不希望回车展开下拉可以设置 comb.ShowDropDownWhenEnter = false;
- private void FpSpread1_EditModeOn(object sender, EventArgs e)
- {
- var a = fpSpread1.EditingControl;
- if (fpSpread1.EditingControl is FpCombo)
- {
- var comb = fpSpread1.EditingControl as FpCombo;
- comb.DroppedDown = true;
- comb.KeyPress += Comb_KeyPress;
- comb.ShowDropDownWhenEnter = false;
- }
- }
- private void Comb_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (e.KeyChar == (char)Keys.Enter && !(sender as FpCombo).DroppedDown)
- {
- fpSpread1.EditMode = false;
- }
- }
复制代码 回车下一行并自动展开需要实现 Aciton
- private void Form1_Load(object sender, EventArgs e)
- {
- InputMap im = fpSpread1.GetInputMap(InputMapMode.WhenFocused);
- ActionMap am = fpSpread1.GetActionMap();
- im.Put(new Keystroke(Keys.Enter, Keys.None), "MoveNextAndStartEditAction");
- am.Put("MoveNextAndStartEditAction", new MoveNextAndStartEditAction());
- }
复制代码
- class MoveNextAndStartEditAction : FarPoint.Win.Spread.Action
- {
- public override void PerformAction(object source)
- {
- if (source is SpreadView)
- {
- SpreadView spread = (SpreadView)source;
- SheetView sheet = spread.Sheets[spread.ActiveSheetIndex];
- ActionMap am = spread.GetActionMap();
- var nextAction = am.Get(SpreadActions.MoveToNextRow);
- if (nextAction != null)
- {
- nextAction.PerformAction(source);
- if (sheet.ActiveCell.CellType is ComboBoxCellType)
- {
- spread.EditMode = true;
- }
- }
- }
- }
- }
复制代码
|