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.
Syncfusion Feedback

Different Color in the Grid

Thread ID:

Created:

Updated:

Platform:

Replies:

54032 Dec 28,2006 12:12 AM Dec 28,2006 02:11 AM Windows Forms 1
loading
Tags: GridControl
dhana
Asked On December 28, 2006 12:12 AM

Hi haneef!

My problem is that I have to assign the color to the Rows in the grid at runtime.

For Example:

the first 10 records may be one color
the another set of 5 records may be in another color and it continues for various group.

Thing is that i am not able to predict the no.of records for each group it depends on database.

how to handle it.I tried in different ways it leads to error when no.of records changes.

awaiting for ur reply.

Regards

Dhana

Administrator [Syncfusion]
Replied On December 28, 2006 02:11 AM

Hi Dhana,

Are you using GroupingGridControl? If so, you can get the group name of the record and set the color of the record depends on the group name by using QueryCellStyleInfo event. Here is a code snippet to show this.

private void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
Element el=e.TableCellIdentity.DisplayElement ;
if(el != null && el.ParentGroup != null
&& el.ParentGroup.Category != null )
{
string GroupName = el.ParentGroup.Category.ToString() ;
switch(GroupName)
{
case "Market Data":
e.Style.BackColor = Color.Goldenrod;
break;
case "Data":
e.Style.BackColor = Color.Pink ;
break;
case "Credit":
e.Style.BackColor = Color.PowderBlue ;
break;
case "Market":
e.Style.BackColor = Color.Gray ;
break;
case "Credit Data":
e.Style.BackColor = Color.Red;
break;
default:
e.Style.BackColor = Color.White;
break;
}
}
}

Please refer to the attached sample for implementation.
GRoupingColors.zip

Best Regards,
Haneef

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.

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

;