Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • Hello,


                                    I have a report with basically two columns, Type and Amount.

                                    They are both represented with XRLabels in a detail band.


                                    In the code, there are two situations I account for. When a total is displayed, I change the font to bold using this code:


                                    private void lblAmount_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)

                                    {

                                    try

                                    {

                                    var label = (XRLabel)sender;


                                    if (GetCurrentColumnValue("Type").ToString().Equals("Total Amount"))

                                    {

                                    label.Font = new Font("Arial", 10, FontStyle.Bold);

                                    }

                                    .....

                                    This works great.


                                    Here is my problem:


                                    In rare cases, I need to change the format string for Amount to percentage.


                                    If I use nearly identical code to what is shown above:


                                    if (GetCurrentColumnValue("Type").ToString().Equals("Average Discount Percent over the Date Range"))

                                    {

                                    label.DataBindings["Text"].FormatString = "{0:0.00%}";

                                    }


                                    Then the format string is being applied to the next row, rather than the one intended.


                                    How can I change the format string programmatically, and have it apply to the row I want?

                                Example.png
                                You must  log in  or  register  to leave comments

                                1 Solution

                                1

                                Hi Ben,

                                To resolve this problem, I suggest that you change the Text property directly instead of changing Bindings :

                                	
                                [C#]
                                var label = (XRLabel)sender; label.Text = Convert.ToDouble(this.GetCurrentColumnValue("FieldName")).ToString("c2");
                                Please try this solution and let us know the results.

                                • barrett777 10.03.2012

                                  Perfect! Thanks :)

                                • Hi Ben,

                                  I am glad to hear that the problem has been resolved. Thank you for letting us know of your progress.
                                  Please feel free to contact us in case of any difficulty. We will be happy to assist you.

                                You must  log in  or  register  to leave comments

                                To start a chat you should create a support ticket


                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners