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. Image for the cookie policy date

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;
			e.Style.BackColor = Color.White;

Live Chat Icon For mobile
Up arrow icon