Alternating color for DataBoundGrid

Hi,

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

Thanks,
Dheeraj

1 Reply

AD Administrator Syncfusion Team 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

Loader.
Up arrow icon