Edit change event

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

  • Posted 8 September 2017, 1:08 pm EST

     Hi


     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), "-#.#"))"

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

    FpSpread1.ActiveSheet.SetText(e.Row, e.Column, Format((val / 100), "-#.#"))


    End Sub

    When i use Percent Celltype the values are cleared when  Edit change event is Triggered again and displaying Zero.


     Ashok

  • Replied 8 September 2017, 1:08 pm EST

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

    http://www.clubfarpoint.com/Forums/forums/thread/27070.aspx

    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