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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Alternating Row Colors.

Thread ID:





608 Jul 16,2002 02:20 PM UTC Jul 16,2002 03:02 PM UTC WinForms 1
Tags: GridControl
Scott Todd
Asked On July 16, 2002 02:20 PM UTC

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

Clay Burch [Syncfusion]
Replied On July 16, 2002 03:02 PM UTC

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;
			e.Style.BackColor = Color.Blue;
		e.Handled = true;


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon