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.

ggc custom row color

Thread ID:

Created:

Updated:

Platform:

Replies:

57168 Feb 27,2007 06:21 AM Feb 28,2007 06:49 PM Windows Forms 5
loading
Tags: GridControl
Ryan Hardoon
Asked On February 27, 2007 06:21 AM

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 05:15 PM

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.

sample:
CustomColor.zip

Best Regards,
S.Shyam.


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

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 ?


GroupSelection.zip

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

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 06:36 AM

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 06:49 PM

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

this.gridGroupingControl1.Invalidate()

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;
}
else
{
e.Style.Enabled = true;
e.Style.BackColor = Color.White;
}
sample: CheckBoxRowHeader.zip

Best Regards,
S.Shyam.

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.

;