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.
Syncfusion Feedback

GridDataBoundGrid single cell operations

Thread ID:

Created:

Updated:

Platform:

Replies:

2523 Jan 27,2003 10:36 PM Jan 28,2003 08:58 AM Windows Forms 2
loading
Tags: GridControl
Bill Korchinski
Asked On January 27, 2003 10:36 PM

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 02:18 AM

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 08:58 AM

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.

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

;