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 Background color for Grid rows

Hello, How can I have a grid with first row background, let''s say, yellow, 2nd one white, 3rd yellow and so on? Is there a property for that or must I paint them myself? Thank you in advance. FJ

1 Reply

AD Administrator Syncfusion Team August 13, 2004 02:53 PM UTC

To color alternate rows in a GridDataBoundGrid you would have to use the PrepareViewStyleInfo event.
private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
	if(e.RowIndex > 0 && e.ColIndex > 0)
		if(e.RowIndex % 2 == 1)
			e.Style.BackColor = Color.LightBlue;
			e.Style.BackColor = Color.DodgerBlue;

Live Chat Icon For mobile
Up arrow icon