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

Question about Alternate Row colors

Thread ID:

Created:

Updated:

Platform:

Replies:

96211 Aug 27,2010 02:16 PM UTC Sep 6,2010 05:21 AM UTC Windows Forms 7
loading
Tags: GridControl
David Mecteaux
Asked On August 27, 2010 02:16 PM UTC

Hi,

I know that you can make all the even rows be a different color by code like:

gridReport.TableDescriptor.Appearance.AlternateRecordFieldCell.BackColor


But how do you make the odd rows be a different color?

Jisha Joy [Syncfusion]
Replied On August 30, 2010 07:30 AM UTC

Hi David,

You could achieve the desired behavior by handling TableControlPrepareViewStyleInfo event.

void gridGroupingControl1_TableControlPrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e)
{
GridTableCellStyleInfo style = (GridTableCellStyleInfo)e.Inner.Style;
if (style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell)

{
e.Inner.Style.BackColor = Color.Lavender;

}
}

Regards,
Jisha

David Mecteaux
Replied On August 30, 2010 08:43 PM UTC

Thanks for the response. Could you also give me some code to change the Color of the odd and even rows when dealing with a Detail table (instead of just the Master table)?

Thanks.

Jisha Joy [Syncfusion]
Replied On September 2, 2010 07:07 AM UTC

Hi David,

Please see the code to change the Color of the odd and even rows in both master and detail table.

void gridGroupingControl1_TableControlPrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e)
{
GridTableCellStyleInfo style = (GridTableCellStyleInfo)e.Inner.Style;
if (style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell)
{
e.Inner.Style.BackColor = Color.Lavender;

}
if (style.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell )
{
e.Inner.Style.BackColor = Color.PaleGoldenrod;

}
}

Sample attached.

Regards,
Jisha



CS_13297ed5.zip

David Mecteaux
Replied On September 2, 2010 01:51 PM UTC

Hi,

I do realize how to change the odd and even row colors globally for each Table. But I was hoping to have a different odd/even color for each Table and not the same color scheme.

So my master table might be pink and tan.
My Detail_1 table might be yellow and orange.
My Detail_2 table could be light red and purple.




Jisha Joy [Syncfusion]
Replied On September 3, 2010 10:23 AM UTC

Hi David,

Please refer the following browser sample that shows how you can customize the appearance of nested tables in GridGroupingControl.

..\\Windows\Grid.Grouping.Windows\Samples\2.0\Appearance\Table Style Demo\cs

Regards,
Jisha


David Mecteaux
Replied On September 3, 2010 02:23 PM UTC

Thanks Jisha!
That was exactly what I was looking for.


Jisha Joy [Syncfusion]
Replied On September 6, 2010 05:21 AM UTC

Hi David,

Thank you for your update.

Regards,
Jisha


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

;