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

GridDataBoundGrid single cell operations

Thread ID:

Created:

Updated:

Platform:

Replies:

2523 Jan 28,2003 03:36 AM UTC Jan 28,2003 01:58 PM UTC WinForms 2
loading
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)
	{
		try
		{
			//this assumes cell is an int
			int cellValue = int.Parse(e.Style.Text);
			if(cellValue > 10)
				e.Style.BackColor = Color.Red;
		}
		catch{}//empty
	}
}

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

Works great- thanks!

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.

Please sign in to access our forum

or the page will be automatically redirected to 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

;