This is a migrated thread and some comments may be shown as answers.

Dynamically set background color in Table Rows

3 Answers 798 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Peter Voigtmann
Top achievements
Rank 1
Peter Voigtmann asked on 25 Mar 2010, 01:25 PM
Hi Telerik Team,

I have a table in one of my reports and I now want to change the background color of specific rows, depending of data which is contained in the row.

How can I achieve that?

Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 29 Mar 2010, 12:51 PM
Hello Peter Voigtmann,

The best way to change the background color is to use Conditional Formatting.

Let me know If you need additional assistance.

Best wishes,
Peter
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Andrei
Top achievements
Rank 1
answered on 22 Dec 2012, 09:59 AM
How to change background color in table row programmatically ? The cell property "Background" does not work.
0
IvanY
Telerik team
answered on 27 Dec 2012, 01:46 PM
Hi Andrei,

To set the background color of a table row, you need to set the background colors for all the cells in the row. 
You can set the background color of the textbox in the cell like this:
this.textBox1.Style.BackgroundColor = System.Drawing.Color.Yellow;

However, the suggested approach for changing the styles of items at run time is by using Conditional Formatting, as it gives you great flexibility over the styling of items.
Another approach is to combine Bindings with User Functions. You can bind the Style.Background property of certain items to your custom user function which returns System.Drawing.Color and you can pass the value of the cell as an argument to that function. This way you can work with the runtime data and provide more complex custom over the color that will be returned. 

Kind regards,
IvanY
the Telerik team

HAPPY WITH REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

Tags
General Discussions
Asked by
Peter Voigtmann
Top achievements
Rank 1
Answers by
Peter
Telerik team
Andrei
Top achievements
Rank 1
IvanY
Telerik team
Share this question
or