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

color coding rows

Thread ID:

Created:

Updated:

Platform:

Replies:

11621 Mar 11,2004 05:43 PM UTC Dec 10,2004 10:21 AM UTC Windows Forms 8
loading
Tags: Grouping
Administrator [Syncfusion]
Asked On March 11, 2004 05:43 PM UTC

hi, i''d like to color code all detail rows according to the value of a certain field in each row, not affecting group headers. any ideas? TIA

Administrator [Syncfusion]
Replied On March 11, 2004 09:29 PM UTC

You can use GridConditionalFormatDescriptor to do this. Below is a sample link. //color rows and alternates rows if their Age value is between 30 and 40. GridConditionalFormatDescriptor format = new GridConditionalFormatDescriptor("specialColor"); format.Expression = "[Age] > 30 And [Age] < 40"; format.Appearance.AlternateRecordFieldCell.BackColor = Color.LightGoldenrodYellow; format.Appearance.AnyRecordFieldCell.BackColor = Color.LightBlue; this.gridGroupingControl1.TableDescriptor.ConditionalFormats.Add(format); GroupingDataSample_3560.zip

Administrator [Syncfusion]
Replied On March 12, 2004 12:09 PM UTC

Thanks, that''s great! i have a problem with a boolean field, or bit in sql. format.Expression = "[Completed] = False"; format.Expression = "[Completed] = 0"; or just format.Expression = "[Completed]"; none seem to work. i tried an integer field and it works. tia

Administrator [Syncfusion]
Replied On March 12, 2004 12:26 PM UTC

having trouble with string fields too, such as format.Expression = "[Full/Empty] = ''E''";

Administrator [Syncfusion]
Replied On March 12, 2004 01:31 PM UTC

You use LIKE to work with strings (and bool values). You can also use match. The strings have to be in single quotes. ''OK is a checkbox column format.Expression = "[OK] LIKE ''true''" ''states that start with N format.Expression = "[State] LIKE ''N*''" ''only NC format.Expression = "[State] LIKE ''NC''"

Administrator [Syncfusion]
Replied On March 12, 2004 01:56 PM UTC

Around the literals should be only one single quote on each side. I think the web interface has added the additional one you see.

Administrator [Syncfusion]
Replied On March 12, 2004 02:55 PM UTC

you guys should get half my salary! hehe!

Frances
Replied On December 8, 2004 10:32 PM UTC

What would the Format.Expression look like if the underlying data type is a SqlDateTime? For example I want to change the background colour of all rows with a CreatedAt date < ''2004-12-01''. The cell data looks like ''2004-12-07 12:34 PM'' etc. This doesn''t work for me: format.Expression = "[CreatedAt] < 2004-12-01"; What should I be using in this scenario?

Administrator [Syncfusion]
Replied On December 10, 2004 10:21 AM UTC

You would need to use the ''between'' operator to compare dates. Here is the section from the User Guide on between. between - Checks if a date field value between the two values is listed in the right-hand operand. For example, [date] between {2/25/2004, 3/2/2004} returns 1 for any record whose date field is greater or equal 2/25/2004 and less than 3/2/2004. To represent the current date, use the token TODAY. To represent DateTime.MinValue, leave the first argument empty. To represent DateTime.MaxValue, leave the second argument empty. GridConditionalFormatDescriptor format = new GridConditionalFormatDescriptor("Before Dec"); format.Expression = "[CreateDate] between {,2004-12-01}"; format.Appearance.AlternateRecordFieldCell.BackColor = Color.LightGoldenrodYellow; format.Appearance.AnyRecordFieldCell.BackColor = Color.LightGoldenrodYellow; this.gridGroupingControl1.TableDescriptor.ConditionalFormats.Add(format);

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

;