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

Alternating color for DataBoundGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

52315 Nov 27,2006 06:00 AM UTC Nov 27,2006 07:04 AM UTC WinForms 1
loading
Tags: GridControl
Dheeraj
Asked On November 27, 2006 06:00 AM UTC

Hi,

I want to have alternating colors for DataBoundGrid, I don't see any property. Is there a way?

Thanks,
Dheeraj

Administrator [Syncfusion]
Replied On November 27, 2006 07:04 AM UTC

Hi Dheeraj,

You can handle the PrepareViewStyleInfo event and set the backcolor for the alternate rows in a grid. Here is a code snippet to show this.

private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if( e.RowIndex > 0 && e.ColIndex > 0 )
{
if( e.RowIndex % 2 == 0)
e.Style.BackColor = Color.Gray;
else
e.Style.BackColor = Color.AliceBlue ;
}
}

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

;