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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to customize the Foreground color for cells in a column based on the cell content?

SfDataGrid displays all the text values in GridCells with a default Foreground color of RGB values 51. However SfDataGrid allows you to customize the Foreground color of the GridCells for the entire view and also to some specific cells based on conditions. 

To change the Foreground color of the GridCells for the entire view, you can use the SfDataGrid.GridStyle property and set the custom style to change the foreground color. For more details please refer our user documentation in the below link.

https://help.syncfusion.com/xamarin-ios/sfdatagrid/styles

In case, if your requirement is to change the Foreground color based on the cell value, then you can achieve this by creating custom GridCell derived from GridCell in SfDataGrid.

Refer the below code example for loading views inside the GridCell to customize its Foreground color based on cell value. The foreground of the GridCells of the Percentage column are applied with red color for values < 50 and green color for values > 50.

ViewController.cs

 

CustomCell.cs

 

Refer the following screenshot for the final outcome upon execution of the above code

The working sample for this KB is available in the following location.

http://www.syncfusion.com/downloads/support/directtrac/general/ze/CellForeground1672404492

Article ID: Published Date: Last Revised Date: Platform: Control:
6224 02/08/2016 11/04/2016 Xamarin.iOS SfDataGrid
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon