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

How to change cell color in DataBoundGrid


Hi Haneef ... How can i change the back color of any particular cell in Data Bound Grid ...
I have tried using the following code but it's not working.

gridDataBound1[1,1].BackColor = Color.Red;
or
gridDataBound1.Model[1,1].BackColor = Color.Red;

1 Reply

AD Administrator Syncfusion Team December 26, 2006 12:46 PM UTC

Hi Ubaid,

By default, DataBoundGrid doesn't store any style info properties. You can not set any cell or row specific properties for the DataBoundGrid other than the CellValue. You need to handle the PrepareViewStyleInfo (or Model.QueryCellInfo) Event to do this. Through this event you can set the style properties for the grid.

To set the BackColor for a cell, you check for the e.RowIndex/e.ColIndex, if that points to the row you desired, set the e.Style.BackColor for it.

See the KnowledgeBase Articles for more info.
QueryCellInfo event : http://www.syncfusion.com/Support/article.aspx?id=10351
PrepareViewStyleInfo event :http://www.syncfusion.com/Support/article.aspx?id=560

Please let me know if this helps.
Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon