KeyPress Problem

Posted by: sandipan on 8 September 2017, 1:45 pm EST

  • Posted 8 September 2017, 1:45 pm EST


    I am using Farpoint Speread for Win Forms 4. I am having a Keypress validation that when the user types a value in the cell The value can be in format

    "Serial: " <Number>.

     for example values can be Serial 1, Serial 2, etc

    Now in the validation , when the user presses <back space> key , i don't want the word 'Serial' to be removed. In other word , if the backspace is applied on a on "Serial 123" then it should work until "Serial", but once only "Serial" is left , I do not want the back space key to remove anything.

    Can anybody show me how to do it from the Key Press Handler. Some code would be appreciated




  • Replied 8 September 2017, 1:45 pm EST


    How about using a MaskCellType. Then you do not have to set up a Key event to monitor keystrokes.

    <FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Dim</FONT></FONT><FONT size=2> m </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>New</FONT></FONT><FONT size=2> FarPoint.Win.Spread.CellType.MaskCellType

    m.Mask = </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"SERI\A\L: #####"

    </FONT></FONT><FONT size=2>

    m.MaskChar = </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>" "

    </FONT></FONT><FONT size=2>

    FpSpread1.Sheets(0).Cells(1, 1).CellType = m

  • Replied 8 September 2017, 1:45 pm EST

    One way to accomplish this that you may not have considered is the MaskcellType


            Dim cbc As New MaskCellType
            cbc.Mask = "Serial: #"
            FpSpread1.ActiveSheet.Cells(1, 1).CellType = cbc



Need extra support?

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

Learn More

Forum Channels