We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Cell Font Colour

Hi, I have two cells within a row. I need to change the font colour dependant on their values i.e. if cell1 is less than cell2 then make it''s font colour red etc. Where is the best place to do this. Thanks

5 Replies

AD Administrator Syncfusion Team February 1, 2005 09:33 AM UTC

Try using PrepareViewStyleInfo. When e.RowIndex and e.ColIndex point to the cell you want to potentially color, compare e.Style.CellValue to your grid cell value (gotten by indexing; grid[e.RowIndex, someColIndex].CellValue). Then set e.Style.BackColor to the color based on teh result of the comparison.


IA Iain February 1, 2005 09:41 AM UTC

Hi, Thanks for the super fast response. I have done this and it works well however I would like to change the font colour but can''t find the right property. Many thanks Iain >Hi, > >I have two cells within a row. I need to change the font colour dependant on their values i.e. if cell1 is less than cell2 then make it''s font colour red etc. Where is the best place to do this. > >Thanks


AD Administrator Syncfusion Team February 1, 2005 09:57 AM UTC

Try using e.Style.TextColor.


SU sukisj@suk.sas.com February 1, 2005 10:03 AM UTC

Hi Clay, I tried e.Style.BackColor and it works. When I try e.Style.TextColor it doesn''t. Any ideas? Thanks Iain


AD Administrator Syncfusion Team February 1, 2005 10:19 AM UTC

Instead of PrepareViewStyleInfo, use grid.QueryCellInfo (grid.Model.QueryCellInfo in a GridDataBoundgrid). There are some properties that need to be set in QueryCellInfo instead of PrepareViewStyleInfo. The TextColor property could be used to initialize some type of edit control, and this would need to be set up early.

Loader.
Live Chat Icon For mobile
Up arrow icon