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

Colouring Rows

Thread ID:





21461 Nov 10,2004 11:01 PM UTC Nov 12,2004 09:26 AM UTC WinForms 3
Tags: Grouping
David Llewellyn
Asked On November 10, 2004 11:01 PM UTC

Hello, I am currently using PrepareViewStyleInfo to change the colour of a Row in a grouped table (GridGroupingControl), when a Row/Column is set to say ''True''. This value cannot be changed, so the colour doesnt need to be changed, once it has loaded. But changing the colour in PrepareViewStyleInfo slows the table down. Is there another way to set the colours? Thanks, David.

Administrator [Syncfusion]
Replied On November 11, 2004 09:25 AM UTC

Another way you can do this is to use conditional formats. GridConditionalFormatDescriptor cfd = new GridConditionalFormatDescriptor("Big"); cfd.Expression = "[Col2] > 4"; cfd.Appearance.AnyCell.BackColor = Color.LightBlue; this.gridGroupingControl1.TableDescriptor.ConditionalFormats.Add(cfd); Here is a forum thread with another sample. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=11621

David Llewellyn
Replied On November 12, 2004 07:35 AM UTC

Hello Clay, Thank you for the information. Is there anyway to write an expression that will filter out records which are equal to say, "Bob". I would then like to colour the row. Something like -> cfd.Expression = "[ColumnName] = Bob"; cfd.Appearance.AnyCell.BackColor = Color.LightBlue; this.gridcontrol.TableDescriptor.ConditionalFormats.Add(cfd); I have tried this to no avail. Should I be enclosing the "Bob" string in quotes or something? Or am I unable to use the expression like this? I have also got another question that is related to my previous one. I am setting the cells tooltip, in PrepareViewStyleInfo, to the same value that is displayed in that cell. Something like this :- private void TableControl_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e) { GridRecordRow rec = this.gridcontrol.Table.DisplayElements[e.RowIndex] as GridRecordRow; if(rec != null) { DataRowView colorrow = rec.GetData() as DataRowView; try { if ((e.ColIndex > 3) && (e.ColIndex < 7)) e.Style.CellTipText = colorrow[e.ColIndex-3].ToString(); } catch { } } } This method REALLY slows down the grouping grid. Do you know of a better way of setting the tooltips of the cells? Thanks again. David.

Administrator [Syncfusion]
Replied On November 12, 2004 09:26 AM UTC

You would use the Like operator. cfd.Expression = "[ColumnName] LIKE ''Bob''"; You use single quotes to delimit a string for the LIKE operator. (The web interface may double the single quote in teh above line.) You could also use the MATCH operator.


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