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
close icon

Conditional formatting

I'm working with the GridGroupingControl. I've got a column that consists of a fixed list of numeric IDs (1, 2, 3). What I would like to do is replace those IDs with readable values at runtime:

1 = Hello
2 = Goodbye
3 = Ciao

I've been looking at conditional formatting, but can't find a way to replace the number with strings. (It works great for adjusting appearance settings, however.)

Am I looking in the wrong place?


Cheers, Jon

2 Replies

HA haneefm Syncfusion Team May 16, 2007 11:21 PM UTC

Hi Jon,

If you are using a GridGroupingControl, then use TableControlDrawCellDisplayText event and set e.DisplayText there to easily control what text is drawn in the cell.

void gridGroupingControl1_TableControlDrawCellDisplayText(object sender, GridTableControlDrawCellDisplayTextEventArgs e)
{
GridTableCellStyleInfo style = (GridTableCellStyleInfo)e.Inner.Style;
if(style.TableCellIdentity.Column != null
&& style.TableCellIdentity.Column.MappingName == "ColumnName")
{
object objValue = e.Inner.Style.CellValue;
f( objValue != null
&& objValue.ToString() != string.Empty)
{
int iCellValue = int.Parse(objValue.ToString());
switch(iCellValue)
{
case 1:
e.Inner.DisplayText = "Hello";
break;
case 2:
e.Inner.DisplayText = "Goodbye";
break;
case 3:
e.Inner.DisplayText = "Ciao";
break;
}
}
}
}

Best regards,
Haneef


JP Jon Pope May 17, 2007 02:27 AM UTC

Thanks, that did the trick!

Loader.
Live Chat Icon For mobile
Up arrow icon