none
Custom string formatter? RRS feed

  • Question

  • Hi,

     

    Is it possible to write a custom string formatter for use by the report viewer?

     

    Specifically, I have a number such as 123 that I wish to display as 120 (ie only 2 sig figs). I can write a custom formatter to achieve this, but I'm not sure how to hook it in to the reportviewer's formatting. I've been using 'g2' as the format string, but naturally this display 123 as 1.2e2, which is not desired.

     

    Thanks for any pointers.

     

    Granta Guy

    Thursday, February 14, 2008 1:08 PM

Answers

  • I'm not 100% sure what your trying to accomplish with your strings.... but you can write methods into any report.  In the blank area under the report, right click and choose properties.  Then click on the CODE tab.

     

    On the Code tab you can add a Visual Basic Method.    And you access it from a control on your report by using the expression

     


    Code.MyMethodName(Fields!FirstParam.Value,.....)

     

     

    for instance I use a method to split a string and go through the array to return only the value I want to display.

     

    Thursday, February 14, 2008 3:04 PM