Edit change event

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

  • Posted 8 September 2017, 1:08 pm EST

    <P> Hi </P>
    <P> I am working on a vb.NET project using farpoint spread for windows forms  3.0.</P>
    <P>I want to display negative values in the spread in a number cell type column.</P>
    <P>when the user enters 5 i want to display it as " - 5". </P>
    <P>i tried the following code in edit change event  but didnt work..</P>
    <P>Edit change event is Triggered again in the the following line of code.</P>
    <P>" FpSpread1.ActiveSheet.SetText(e.Row, e.Column, Format((val / 100), <SPAN class=st>"-#.#"</SPAN>))"<BR></P><PRE class=coloredcode> <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.</P>
    <P> Ashok</P>
  • Replied 8 September 2017, 1:08 pm EST

    One idea might be to use a formula or a custom celltype:<br><br>http://www.clubfarpoint.com/Forums/forums/thread/27070.aspx<br><br>Did you set the min and max values for the percent cell?<br>
  • 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...<br><br>Public Class myNumber<br>  Inherits FarPoint.Win.Spread.CellType.NumberCellType<br><br>  Public Sub New()<br>    DecimalPlaces = 0<br><br><br>  End Sub<br><br>  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)<br>    If Not value Is Nothing Then<br>    Dim s As String = "-#.#"<br><br>Dim tempD As Double = Convert.ToDouble(value)<br><br>value = tempD.ToString(s)<br><br>value = Convert.ToDouble(value)<br>End If<br>    MyBase.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor)<br>  End Sub<br>End Class<br>
Need extra support?

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

Learn More

Forum Channels