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.

Alternating Row Colors.

Thread ID:

Created:

Updated:

Platform:

Replies:

608 Jul 16,2002 10:20 AM Jul 16,2002 11:02 AM Windows Forms 1
loading
Tags: GridControl
Scott Todd
Asked On July 16, 2002 10:20 AM

Is there an easy way to alternate the row color in a data bound grid? Scott

Clay Burch [Syncfusion]
Replied On July 16, 2002 11:02 AM

Normally, we would recommend you handle PrepareViewStyleInfo to alternately color rows, but in the current release (RC2) of GridDataBoundGrid, this event is not being fired. So, for the time being, you can do this by handling QueryCellInfo instead. Here are some code snippets.
//hook the handler in Form_Load...
this.gridDataBoundGrid2.Model.QueryCellInfo += new GridQueryCellInfoEventHandler(HandleQueryCellInfo);

//the handler
private void HandleQueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
	if(e.ColIndex > 0 && e.RowIndex > 0)
	{
		if(e.RowIndex % 2 == 0)
			e.Style.BackColor = Color.Red;
		else 
			e.Style.BackColor = Color.Blue;
		e.Handled = true;
	}
}
	 

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.

;