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.

Individual cell colors in GridDataBoundGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

46352 Jul 11,2006 01:56 PM Jul 11,2006 02:58 PM Windows Forms 2
loading
Tags: GridControl
Susie Smith
Asked On July 11, 2006 01:56 PM

How do I change the background color the current cell in the GridDataBoundGrid when a specific event happens? The PrepareViewStyleInfo doesn''t work well for this. thanks

Administrator [Syncfusion]
Replied On July 11, 2006 02:32 PM

Hi Susie, 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 currentcell, you check for the e.RowIndex/e.ColIndex, if that points to the row you desired, set the e.Style.BackColor for it. Here is some code snippet. //PrepareViewStyleInfo or Model.QueryCellInfo event GridCurrentCell cc = this.grid.CurrentCell; if( e.RowIndex == cc.RowIndex && e.ColIndex == cc.ColIndex ) { e.Style.BackColor = Color.Red; } KnowledgeBase Articles: 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

Susie Smith
Replied On July 11, 2006 02:58 PM

>Hi Susie, > >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 currentcell, you check for the e.RowIndex/e.ColIndex, if that points to the row you desired, set the e.Style.BackColor for it. Here is some code snippet. > >//PrepareViewStyleInfo or Model.QueryCellInfo event >GridCurrentCell cc = this.grid.CurrentCell; >if( e.RowIndex == cc.RowIndex && e.ColIndex == cc.ColIndex ) >{ > e.Style.BackColor = Color.Red; >} > >KnowledgeBase Articles: >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 Ok I ended up turning the event on and off because I want the cell color to change under certain situations. thanks Susie

CONFIRMATION

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.

;