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

How to give conditional formating programatically.

0 Answers 73 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Allan Hill
Top achievements
Rank 1
Allan Hill asked on 16 Feb 2010, 12:43 PM
Hi,
    I am generating cross-tab report for whole month. so based on status, i want to show colors. e.g. for 0-Green, 1-Red, 2-LightGreen, 3-Orange, 4-LightYellow, 5-LightPink. when i have given condition formating to first column, it wrote this many lines of code in to the designer. but i want to do it for 31 columns. what is the alternative for this? Also there is limitation of code is, my field will be changed at runtime. it is not fixed that, for txtD1, always field is Fields.D01.

please let me know. following is the code sample.

formattingRule1.Filters.AddRange(new Telerik.Reporting.Data.Filter[] {
            new Telerik.Reporting.Data.Filter("=Fields.D01", Telerik.Reporting.Data.FilterOperator.Equal, "3")});
            formattingRule1.Style.BackgroundColor = System.Drawing.Color.Orange;
            formattingRule1.Style.Color = System.Drawing.Color.Transparent;
            formattingRule2.Filters.AddRange(new Telerik.Reporting.Data.Filter[] {
            new Telerik.Reporting.Data.Filter("=Fields.D01", Telerik.Reporting.Data.FilterOperator.Equal, "1")});
            formattingRule2.Style.BackgroundColor = System.Drawing.Color.Red;
            formattingRule2.Style.Color = System.Drawing.Color.Transparent;
            formattingRule3.Filters.AddRange(new Telerik.Reporting.Data.Filter[] {
            new Telerik.Reporting.Data.Filter("=Fields.D01", Telerik.Reporting.Data.FilterOperator.Equal, "0")});
            formattingRule3.Style.BackgroundColor = System.Drawing.Color.Green;
            formattingRule3.Style.Color = System.Drawing.Color.Transparent;
            formattingRule4.Filters.AddRange(new Telerik.Reporting.Data.Filter[] {
            new Telerik.Reporting.Data.Filter("=Fields.D01", Telerik.Reporting.Data.FilterOperator.Equal, "2")});
            formattingRule4.Style.BackgroundColor = System.Drawing.Color.LightGreen;
            formattingRule4.Style.Color = System.Drawing.Color.Transparent;
            formattingRule5.Filters.AddRange(new Telerik.Reporting.Data.Filter[] {
            new Telerik.Reporting.Data.Filter("=Fields.D01", Telerik.Reporting.Data.FilterOperator.Equal, "5")});
            formattingRule5.Style.BackgroundColor = System.Drawing.Color.LightPink;
            formattingRule5.Style.Color = System.Drawing.Color.Transparent;
            formattingRule6.Filters.AddRange(new Telerik.Reporting.Data.Filter[] {
            new Telerik.Reporting.Data.Filter("=Fields.D01", Telerik.Reporting.Data.FilterOperator.Equal, "4")});
            formattingRule6.Style.BackgroundColor = System.Drawing.Color.LightYellow;
            formattingRule6.Style.Color = System.Drawing.Color.Transparent;
            this.txtD1.ConditionalFormatting.AddRange(new Telerik.Reporting.Drawing.FormattingRule[] {
            formattingRule1,
            formattingRule2,
            formattingRule3,
            formattingRule4,
            formattingRule5,
            formattingRule6});

-Thanks
Rajendra S(rajendra.soni@e-zest.in)

No answers yet. Maybe you can help?

Tags
General Discussions
Asked by
Allan Hill
Top achievements
Rank 1
Share this question
or