AD
Administrator
Syncfusion Team
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
AD
Administrator
Syncfusion Team
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
AD
Administrator
Syncfusion Team
March 12, 2004 12:26 PM UTC
having trouble with string fields too, such as format.Expression = "[Full/Empty] = ''E''";
AD
Administrator
Syncfusion Team
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''"
AD
Administrator
Syncfusion Team
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.
AD
Administrator
Syncfusion Team
March 12, 2004 02:55 PM UTC
you guys should get half my salary! hehe!
FR
Frances
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?
AD
Administrator
Syncfusion Team
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);