Posted 24 February 2026, 11:19 am EST
Hi,
I’ve got the following set of code that I have in the Load Event, as I seek to replicate as much as possible the behavior of Excel with formulas.
Dim im As New FarPoint.Win.Spread.InputMap
'Define the operation of pressing Enter key in cells Not being edited as “Move to the next row”.
im = FpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenAncestorOfFocused)
im.Put(New FarPoint.Win.Spread.Keystroke(Keys.F2, Keys.None), FarPoint.Win.Spread.SpreadActions.StartEditingFormula)
im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Back, Keys.None), FarPoint.Win.Spread.SpreadActions.ClearCell)
im.Put(New FarPoint.Win.Spread.Keystroke(Keys.D0, Keys.Shift), FarPoint.Win.Spread.SpreadActions.StartEditingFormula)
im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Add, Keys.None), FarPoint.Win.Spread.SpreadActions.StartEditingFormula)
im.Put(New FarPoint.Win.Spread.Keystroke(Keys.Oemplus, Keys.None), FarPoint.Win.Spread.SpreadActions.StartEditingFormula)
im.Put(New FarPoint.Win.Spread.Keystroke(Keys.OemMinus, Keys.None), FarPoint.Win.Spread.SpreadActions.StartEditingFormula)
However, this seems to not be working the first time. I am able to enter formulamode after the second time I try. For example, if I press “F2” key, the first time, editmode is activated, the second time and future times I press the “F2” key, FormulaMode is activated.
I do have an EditModeStarting event
Private Sub FpSpread1_EditModeStarting(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.EditModeStartingEventArgs) Handles FpSpread1.EditModeStarting
If FpSpread1.ActiveSheetIndex = 0 Then
FormulaOriginal = If(FpSpread1.ActiveSheet.ActiveCell.Formula, “”)
ValorOriginal = FpSpread1.ActiveSheet.ActiveCell.Value
If FormulaOriginal <> "" Then Formula = FormulaOriginal Else Formula = CStr(If(ValorOriginal Is Nothing, FpSpread1.ActiveSheet.ActiveCell.Text, ValorOriginal)) End If If (FpSpread1.ActiveSheet.ActiveColumnIndex >= Columnas.ColConteoCajas And FpSpread1.ActiveSheet.ActiveColumnIndex <= Columnas.ColReconteoPiezas) Then FpSpread1.ActiveSheet.ActiveCell.CellType = New GeneralCellType End If End If
End Sub
This behavior only occurs with numeric cells, Text cells do start in formulamode since the first time.
