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

How to apply different back colors to different groups.

Hi,

How to apply different back colors to different groups in GridGroupingControl. I used "gridGroupingControl.TableDescriptor.Appearance.GroupCaptionCell.BackColor" and "gridGroupingControl.TableDescriptor.Appearance.GroupCaptionSummaryCell.BackColor" properties which applies colors for all the groups, but I need to use different back colors for different groups. My GridGroupingControl datasource is arraylist and I used more then one GroupedColumn.

Thanks,
Ravi.

6 Replies

J. J.Nagarajan Syncfusion Team September 8, 2007 02:56 AM UTC

Hi Ravi,

Thanks for your interest in Syncfusion product.

You can apply different back colors to the different groups. Please handle QueryCellStyleInfo event and you can set the color by using e.Style.BackColor property. Please refer to the following code snippet

this.gridGroupingControl1.QueryCellStyleInfo += new Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventHandler(gridGroupingControl1_QueryCellStyleInfo);

void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell && e.TableCellIdentity.GroupedColumn != null)
{
if (e.TableCellIdentity.GroupedColumn.Name == "Col1")
e.Style.BackColor = Color.Green;
else if (e.TableCellIdentity.GroupedColumn.Name == "Col2")
e.Style.BackColor = Color.Pink;
else
e.Style.BackColor = Color.Red;
e.Style.Themed = false;
}
}


Please refer to the attached sample that demonstrates this completely.

http://websamples.syncfusion.com/samples/Grid.Windows/F68087/main.htm

Please let me know if you have any questions.

Regards,
Nagaraj


RA Ravi September 10, 2007 03:09 PM UTC

Hi Nagaraj,

Thanks for your reply, your code snipet works. But I need to apply the backcolor for the entire row of the GroupedColumn instead of just one GroupedColumn cell. In your attached sample you merged all the columns of the row as one single cell. I cannot do that, since other columns of the group contains summary values.

Please find the attached sample to understand it clearly.

Thanks,
Ravi.

GropedGridControlSample.zip


J. J.Nagarajan Syncfusion Team September 11, 2007 08:02 PM UTC

Hi Ravi,

If you just want to highlight a record based on a particular column please use the following code snippet

private Record FindRow(string column, string searchString)
{
Record searchRow = null;
foreach (Record rec in gridGroupingControl1.Table.FilteredRecords)
{
if (rec.GetValue(column).ToString() == searchString)
{
searchRow = rec;
gridGroupingControl1.Table.SelectedRecords.Clear();

gridGroupingControl1.Table.SelectedRecords.Add(rec);
rec.SetCurrent(column);
break;
}
}
return searchRow;
}

Please refer to the attached sample. In this sample please do the following

1. Run the sample.
2. Select a cell in Column1.
3. Type "Row1" in that particular cell.
4. Click on the "search" button, you can highlight that parcular Row.

You can download the sample from the following page.

http://websamples.syncfusion.com/samples/Grid.Windows/F68091/main.htm

Please refer to the sample and let me know if you have any questions.

Regards,
Nagaraj


J. J.Nagarajan Syncfusion Team September 11, 2007 09:24 PM UTC

Hi Ravi,

Please ignore the previous update which was intended for another customer.

If you want to apply the backcolor for the entire row of the GroupedColumn then please refer to the following code snippet

this.gridGroupingControl1.TableDescriptor.Columns[0].Appearance.AnyRecordFieldCell.BackColor = Color.Green;
this.gridGroupingControl1.ChildGroupOptions.ShowCaptionSummaryCells = true; this.gridGroupingControl1.TableDescriptor.Appearance.GroupCaptionSummaryCell.BackColor = Color.LightBlue;
this.gridGroupingControl1.TableDescriptor.Appearance.GroupCaptionCell.BackColor = Color.LightBlue;
this.gridGroupingControl1.TableDescriptor.Appearance.GroupCaptionCell.Themed = false;

Please refer to the attached sample that demonstrates this completely. Let me know if you ahve any questions.

http://www.syncfusion.com/Support/user/uploads/Grouping_Color_cfe8c6f3.zip

Regards,
Nagaraj


RA Ravi September 11, 2007 10:36 PM UTC

Hi Nagaraj,

It does not solve my requirement. By the doing the way you suggested, I will get same colors for all the groups. Please let me know if you want me to explain it clear using sample.

Thanks
Ravi.


RA Ravi September 12, 2007 02:30 PM UTC

Hi Nagaraj,

I have created a new incident in Direct Trac related to this issue. Please ignore this thread.

Thanks,
Ravi.


Loader.
Live Chat Icon For mobile
Up arrow icon