Possible issue with NumberCellType

Posted by: j2associates on 8 September 2017, 1:28 pm EST

  • Posted 8 September 2017, 1:28 pm EST

    Hello all,

    In edit mode, a NumberCellType does not appear to process the Delete key. It processes the BackSpace key, so I would expect it to also process the Delete key. Is this behavior by design? Thanks in advance for any ideas and/or suggestions!

  • Replied 8 September 2017, 1:28 pm EST

    j2 -

    No cell type will process the delete key when in edit mode.  See the following thread.

  • Replied 8 September 2017, 1:28 pm EST

    Thanks BobM! For the benefit of others, here is what I came  up with:

    A. Save the editor as a class level variable with events

        ' Editor for the NumberCellType is a GeneralEditor.
        Private WithEvents m_Editor As FarPoint.Win.Spread.CellType.GeneralEditor

        Public Overrides Function GetEditorControl(ByVal appearance As FarPoint.Win.Spread.Appearance, ByVal zoomFactor As Single) As System.Windows.Forms.Control
            m_Editor = DirectCast(MyBase.GetEditorControl(appearance, zoomFactor), GeneralEditor)
            Return m_Editor
        End Function 'GetEditorControl

    B. Place code in editor KeyDown event to handle the Delete key

        Private Sub m_Editor_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles m_Editor.KeyDown
                If e.KeyCode = Keys.Escape Then
                    m_EscapeKeyPressed = True

                ElseIf e.KeyCode = Keys.Delete Then
                    With m_Editor
                        Dim prefix As String = String.Empty
                        If .SelectionStart > 0 Then
                            prefix = .Text.Substring(0, .SelectionStart)
                        End If
                        Dim suffix As String = .Text.Substring(.SelectionStart)
                        If .SelectionStart = 0 Then suffix = suffix.Substring(1)
                        .Text = prefix & suffix
                    End With
                End If
            Catch ex As Exception
            End Try
        End Sub


Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels