Change cells design according to data
Hi!
I'm trying to change the color of some table cells, according to the value of the data in it.
For example, if I have a table with numbers, I want only the cells with values higher than 100 to be red, or write red "!" next to the value.
I tried to do something like this (just as a proof of concept)
report.Load("repory.frx");
report.RegisterData(data, "Data");
TableObject table = (TableObject)report.Pages[0].ChildObjects[2].ChildObjects[0];
TableRow row = table.Rows[0];
TableCell cell = (TableCell)row.ChildObjects[0];
cell.GetData();
now I'm supposed to have the data, but I'm not really sure I can access it or change something in the specific cells design.
Any suggestions?
Thanks
I'm trying to change the color of some table cells, according to the value of the data in it.
For example, if I have a table with numbers, I want only the cells with values higher than 100 to be red, or write red "!" next to the value.
I tried to do something like this (just as a proof of concept)
report.Load("repory.frx");
report.RegisterData(data, "Data");
TableObject table = (TableObject)report.Pages[0].ChildObjects[2].ChildObjects[0];
TableRow row = table.Rows[0];
TableCell cell = (TableCell)row.ChildObjects[0];
cell.GetData();
now I'm supposed to have the data, but I'm not really sure I can access it or change something in the specific cells design.
Any suggestions?
Thanks
Comments
If you want to change the color only, use the conditional highlight feature. It is described in the user's manual, "Report creation/Formatting/Conditional highlighting" chapter. This chapter describes the Text object, but it applies to table cell too.
Thanks.
But can I change the color of just part of the cell text (like in the example I gave, draw red "!" next to the text?
And in general, can I access the table cell's data from the code, and modify the cell accordingly?
Thanks Again
- set cell's HtmlTags property to true;
- write an event handler for the cell's AfterData event (see the Code tab).