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

Dynamically changing Font Style of each row

3 Answers 739 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Monik
Top achievements
Rank 1
Monik asked on 11 Dec 2015, 01:59 PM

Hello, 

I am having a dynamic code based report which generates sales value for certain items. My items are grouped under categories. After each category i am showing a "TOTAL" row to show total value for all items under each category. Thats working fine... Where i am stuck is, i need to show the TOTAL row as BOLD (Font Style). Issue is, the TOTAL row which is added after each category is coming from the Stored Procedure itself. So how can i access Data Value of the CELL in my Report table(Layout) and check if value inside my CELL is "TOTAL" and i make that row as BOLD (Font Style)

I tried the Conditional formatting option that i found on this link http://www.telerik.com/forums/changing-fonts-and-colors-on-a-quot-dynamic-quot-table-based-on-value but this code is in VB and i am working on C#. 

If you can please provide a c# alternative to this it would be greatful

 

Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 12 Dec 2015, 01:09 PM
Hello Monik,

Conditional Formatting rules can be added through the Report Designer. As a condition you can use a field's value. For example:
Filters > Edit Filters dialog
Expression: = Fields.Title
Operator: Like
Value: ='Total'
 When the condition is met the item will be styled based on the properties set through the Style Builder dialog. You can add a field in the data which indicates which rows to be styled differently and then use that field in the conditional formatting rule.

For more details, please check Conditional Formatting.


Let us know if you have any further questions.

Regards,
Stef
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Monik
Top achievements
Rank 1
answered on 14 Dec 2015, 04:38 AM

Hello Stef,

Thanks for the reply, but as I said my report is not designed in any designer. I am generating report from cs code. So what i need here is syntax for setting conditional formatting through cs code.

What i need is, if my =Fields.[Item] contains value as "Total" then i need format it to Bold.

Please tell me what i am missing..

1.Telerik.Reporting.Drawing.FormattingRule FormattingRule1 = new FormattingRule();
2.FormattingRule1.Filters.Add(new Telerik.Reporting.Filter("=Fields.[Item]", Telerik.Reporting.FilterOperator.Equal, "\'Total\'"));
3. 
4.Telerik.Reporting.TextBox textBoxTable = new Telerik.Reporting.TextBox();
5. textBoxTable.ConditionalFormatting.Add(FormattingRule1);

0
Stef
Telerik team
answered on 14 Dec 2015, 11:59 AM
Hello Monik,

When you build a conditional formatting rule with the VS Report Designer, the code in the report's designer.cs looks as:
Telerik.Reporting.Drawing.FormattingRule formattingRule1 = new Telerik.Reporting.Drawing.FormattingRule();
formattingRule1.Filters.Add(new Telerik.Reporting.Filter("= Fields.Item", Telerik.Reporting.FilterOperator.Like, "=\'Total\'"));
formattingRule1.Style.Font.Bold = true;
formattingRule1.Style.Font.Size = Telerik.Reporting.Drawing.Unit.Point(12D);
this.itemDataTextBox1.ConditionalFormatting.AddRange(new Telerik.Reporting.Drawing.FormattingRule[] {
formattingRule1});

My recommendation is to use the VS Report Designer and create and test the rule, and then re-use the auto-generated code from the designer.cs file.

Regards,
Stef
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Monik
Top achievements
Rank 1
Answers by
Stef
Telerik team
Monik
Top achievements
Rank 1
Share this question
or