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.
Unfortunately, activation email could not send to your email. Please try again.

Alternate Background color for Grid rows

Thread ID:

Created:

Updated:

Platform:

Replies:

17690 Aug 13,2004 10:43 AM Aug 13,2004 10:53 AM Windows Forms 1
loading
Tags: GridControl
FJ
Asked On August 13, 2004 10:43 AM

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

Administrator [Syncfusion]
Replied On August 13, 2004 10:53 AM

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;
		else
			e.Style.BackColor = Color.DodgerBlue;
	}
}

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.

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.

;