Problem setting Decimal places in NumericCellType

Posted by: sheritt on 8 September 2017, 1:50 pm EST

  • Posted 8 September 2017, 1:50 pm EST

    I am trying to set 3 decimal places in a column and it will only give me 2.


    In the database I have the field set as double with 3 decimal points and the code I use to set decimal places is as follows...


    Dim cell As New FarPoint.Win.Spread.CellType.NumberCellType


    cell.MaximumValue = 9999999.999


    cell.MinimumValue = 0


    cell.DecimalPlaces() = 3


    col = mfpGrd.ActiveSheet.Columns(iCol)


    col.CellType = cell


     


    What am I doing wrong?


    Thanks


    Sheri

  • Replied 8 September 2017, 1:50 pm EST

    Hello Sheri,

    I tried the below snippet to set Column1 to be of Number type with 3 decimal places and it seems to work as expected.

            Dim numCell As New FarPoint.Win.Spread.CellType.NumberCellType
            numCell.DecimalPlaces = 3
            numCell.MaximumValue = 9999999.999
            numCell.MinimumValue = 0
            FpSpread1.ActiveSheet.Columns(1).Width = 75
            FpSpread1.ActiveSheet.Columns(1).CellType = numCell

    You may also try setting the DataAutoCellTypes to false.Hope it helps.Thanks

  • Replied 8 September 2017, 1:50 pm EST

    Suresh is correct. When bound to a database the celltypes are set based on the type of datafield and your settings are being overridden. You would need to set DataAutoCellTypes to false so that the celltypes will not be set by the data source.
  • Replied 8 September 2017, 1:50 pm EST

    You can also use the FpSpread.DataColumnConfigure event (or the protected OnDataColumnConfigure method, if you are implementing a subclass of FpSpread) to override the data binding configuration for the column.  This event allows you to override specific columns or add additional settings to configure specific columns, while still using the automatic configuration settings for other bound columns.
Need extra support?

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

Learn More

Forum Channels