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

GridDataBoundGrid single cell operations

Thread ID:





2523 Jan 28,2003 03:36 AM UTC Jan 28,2003 01:58 PM UTC WinForms 2
Tags: GridControl
Bill Korchinski
Asked On January 28, 2003 03:36 AM UTC

I have a similar question to a previous one. I need to change the backgroud color of a sinlge cell in a GridDataBoundGrid, based on the most recent value of that cell's contents. What's the most efficient way to do this?

Administrator [Syncfusion]
Replied On January 28, 2003 07:18 AM UTC

Handle PrepareViewStyleInfo and getting the value to be tested from the passed-in style. In your handler, you would conditionally set e.Style.Color by testing the cell value (or cell text) based on whether the e.ColIndex and e.RowIndex pointed to your test cell.
private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
	//test cell 1,4
	if(e.ColIndex == 4 && e.RowIndex == 1)
			//this assumes cell is an int
			int cellValue = int.Parse(e.Style.Text);
			if(cellValue > 10)
				e.Style.BackColor = Color.Red;

Bill Korchinski
Replied On January 28, 2003 01:58 PM UTC

Works great- thanks!


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