Column formatting is lost

Posted by: desarrollo on 3 November 2022, 4:42 am EST

    • Post Options:
    • Link

    Posted 3 November 2022, 4:42 am EST

    Why losts the column format when I run this piece of code?

    Dim cs As C1.Win.C1FlexGrid.CellStyle = FlexGrid.Styles.Add(“Test”)

    cs.Font = New Font(Font_Name, Font_Size)

    cs.TextAlign = C1FlexGrid.TextAlignEnum.LeftCenter

    cs.Format = Columna.Format ’ Ocurs with or without this line

    Columna.Style = cs

    I need to keep the “N2” format to show values with two decimals. The column has that format and shows ok if I don’t asign the style with that code.

    Thanks.

  • Posted 3 November 2022, 8:09 am EST

    Hi,

    When a Column’s Format/DataType is set, a CellStyle is created internally and assigned to that Column, and the Column then follows that DataType to apply the Format. Following that, if you assign a new CellStyle to that column without setting the CellStyle.DataType, then the Column will have its DataType set to “Nothing” and the Format will be lost.

    Therefore, we suggest that you either set the DataType to the new CellStyle OR use the existing CellStyle of the column for its customization instead of assigning a new one.

    We have created a small sample demonstrating the behavior in both the Bound and Unbound Grids.

    If you still face any issues, please update the attached sample to replicate the issue so we can investigate further and assist you better.

    Attachment: FlexGrid_ColumnStyling.zip

    Thanks, and Best Regards,

    Kartik

  • Posted 3 November 2022, 8:26 am EST

    Solved. Easy and clear.

    Thanks!

Need extra support?

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

Learn More

Forum Channels