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

Colouring Rows

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.

3 Replies

AD Administrator Syncfusion Team November 11, 2004 04:25 AM

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


DL David Llewellyn November 12, 2004 02:35 AM

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.


AD Administrator Syncfusion Team November 12, 2004 04:26 AM

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.

Loader.
Live Chat Icon For mobile
Up arrow icon