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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ggc custom row color

Thread ID:





57168 Feb 27,2007 11:21 AM UTC Feb 28,2007 11:49 PM UTC WinForms 5
Tags: GridControl
Ryan Hardoon
Asked On February 27, 2007 11:21 AM UTC

Hi everybody,

I wish to determine ggc row-color on the fly.

so far I tried the following events:
- "myGGC_TableControlDrawCellBackground"
- "myGGC_TableControlDrawCell"
- "myGGC_TableControlCellDrawn"

It appears that they only take effect when I select a specific cell.

What is the correct approach to handle the OnPaint of each cell ?

Thanks in advance.

Administrator [Syncfusion]
Replied On February 27, 2007 10:15 PM UTC

Hi Ryan

In a GridGroupingControl, you cannot set any row specific or cell specific properties like backcolor. To do this, you will have to catch the TableControlPrepareViewStyleInfo event (or QueryCellStyleInfo event). In the event handler code, you can check for the e. TableCellIdentity .RowIndex and if that points to the row you wanted, set the e.Style.BackColor to the color you want.

void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
if (e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)
//Apply colours row wise.
if (e.TableCellIdentity.RowIndex % 2 == 0)
e.Style.BackColor = Color.Pink;

//Color for particular cell alone
if (e.TableCellIdentity.ColIndex == 1)
Element el = e.TableCellIdentity.DisplayElement;
if (el != null && el.Kind == DisplayElementKind.Record)
Record r = el.GetRecord();
object value = r.GetValue("sno");
int s = (int)value;
if (s == 3)
e.Style.BackColor = Color.Blue;


Please try the attached sample and let me know if this helps.


Best Regards,

Administrator [Syncfusion]
Replied On February 28, 2007 09:38 AM UTC

Hi Shyam, and thanks.

The sample application works just fine, but it's not enough for what we need.

We wish to define alternating colors to row-groups of undetermined lengths and a different color for a selected group (see the attachment).

The problem is that when I select a row, only the selected row and the previously selected row are repainted and the rest are repainted only on invalidation (e.g. when the window is hidden and then shown again).

What do I need to do in order to invalidate the other rows ?


Administrator [Syncfusion]
Replied On February 28, 2007 09:44 AM UTC

Another question regarding the attachment.

The CheckBoxes are only relevant to the header rows. is there a way to make the others disappeare ?

Administrator [Syncfusion]
Replied On February 28, 2007 11:36 AM UTC

Another interesting note that might help to pin point the problem.

The invalidation works just fine when I enter a cell's "edit" mode, but it's not complete when I select a "read-only" cell.

Administrator [Syncfusion]
Replied On February 28, 2007 11:49 PM UTC

Hi Ryan,

Question 1) "Invalidate rows"

You can try calling the Invalidate OR refresh method to refresh all rows in a grid. Below is a code snippet


Question 2) "RowHeader CheckBox"

The attached sample describes you "How to add the checkbox in a RowHeader of the GroupingGrid?". It disappears the record row when the rowheader check box value is unchecked. Here is a code snippet to show this.

Hashtable GroupCheckValue = new Hashtable();
if (GroupCheckValue.Contains(e.TableCellIdentity.RowIndex) && GroupCheckValue[e.TableCellIdentity.RowIndex].ToString() == "1")
e.Style.Enabled = false;
e.Style.BackColor = Color.Beige;
e.Style.Enabled = true;
e.Style.BackColor = Color.White;
sample: CheckBoxRowHeader.zip

Best Regards,


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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