Alternate Backcolor for Rows ? (MS DataGrid gives it!)

Hi It seems we have to loop around all the rows to set an alternate colors between rows. Any other ways? why dont you directly have a property like we have in .Net datagrid? Regards Rajaraman California Software, INDIA

1 Reply

AD Administrator Syncfusion Team February 1, 2003 04:59 PM UTC

Handle the PrepareViewStyleInfo event, and then conditionally set the e.Style.BackColor in what ever manner you like. For example, you can do every 3 rows instead of every other row :)
private void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
	if(e.ColIndex > 0 && e.RowIndex > 0)
	{
		if(e.RowIndex % 3 == 0) //use 2 for every other row
			e.Style.BackColor = Color.LightBlue;
		else
			e.Style.BackColor = Color.White;
	}
}

Loader.
Up arrow icon