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.
Unfortunately, activation email could not send to your email. Please try again.

How to change cell color in DataBoundGrid

Thread ID:





53966 Dec 26,2006 07:01 AM Dec 26,2006 07:46 AM Windows Forms 1
Tags: GridControl
Asked On December 26, 2006 07:01 AM

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;
gridDataBound1.Model[1,1].BackColor = Color.Red;

Administrator [Syncfusion]
Replied On December 26, 2006 07:46 AM

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.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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.