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 Backcolor for Rows ? (MS DataGrid gives it!)

Thread ID:

Created:

Updated:

Platform:

Replies:

2577 Feb 1,2003 05:29 AM Feb 1,2003 11:59 AM Windows Forms 1
loading
Tags: GridControl
Rajaraman
Asked On February 1, 2003 05:29 AM

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

Administrator [Syncfusion]
Replied On February 1, 2003 11:59 AM

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;
	}
}

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.

;