Edit change event

Posted by: ashok-k on 8 September 2017, 1:08 pm EST

  • Posted 8 September 2017, 1:08 pm EST


     I am working on a vb.NET project using farpoint spread for windows forms  3.0.

    I want to display negative values in the spread in a number cell type column.

    when the user enters 5 i want to display it as " - 5".

    i tried the following code in edit change event  but didnt work..

    Edit change event is Triggered again in the the following line of code.

    " FpSpread1.ActiveSheet.SetText(e.Row, e.Column, Format((val / 100), <SPAN class=st>"-#.#"</SPAN>))"

     <SPAN class=kwd>Private Sub</SPAN> FpSpread1_EditChange(<SPAN class=kwd>ByVal</SPAN> sender <SPAN class=kwd>As Object</SPAN>, <SPAN class=kwd>ByVal</SPAN> e <SPAN class=kwd>As</SPAN> FarPoint.Win.Spread.EditorNotifyEventArgs) <SPAN class=kwd>Handles</SPAN> FpSpread1.EditChange
    <SPAN class=kwd>Dim</SPAN> val <SPAN class=kwd>As Double</SPAN>
    val = <SPAN class=kwd>CDbl</SPAN>(FpSpread1.ActiveSheet.Cells(e.Row, e.Column).Value)

    FpSpread1.ActiveSheet.SetText(e.Row, e.Column, Format((val / 100), <SPAN class=st>"-#.#"</SPAN>))

    <SPAN class=kwd>End Sub</SPAN></PRE>
    <P>When i use Percent Celltype the values are cleared when  Edit change event is Triggered again and displaying Zero.


  • Replied 8 September 2017, 1:08 pm EST

    One idea might be to use a formula or a custom celltype:


    Did you set the min and max values for the percent cell?
  • Replied 8 September 2017, 1:08 pm EST

    I don't believe you'll be able to format the value from the EditChange event.  Here's a custom celltype that will display the number as negative when you leave the cell...

    Public Class myNumber
      Inherits FarPoint.Win.Spread.CellType.NumberCellType

      Public Sub New()
        DecimalPlaces = 0

      End Sub

      Public Overrides Sub PaintCell(ByVal g As System.Drawing.Graphics, ByVal r As System.Drawing.Rectangle, ByVal appearance As FarPoint.Win.Spread.Appearance, ByVal value As Object, ByVal isSelected As Boolean, ByVal isLocked As Boolean, ByVal zoomFactor As Single)
        If Not value Is Nothing Then
        Dim s As String = "-#.#"

    Dim tempD As Double = Convert.ToDouble(value)

    value = tempD.ToString(s)

    value = Convert.ToDouble(value)
    End If
        MyBase.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor)
      End Sub
    End Class
Need extra support?

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

Learn More

Forum Channels