Welcome to the Xceed Community | Help
Community Search  

Custom Cell Formatting

Sort Posts: Previous Next
  •  10-07-2008, 12:22 PM Post no. 15949

    Custom Cell Formatting

    I am trying to figure out how to suppress the rendering of zero (0.00) values into cells bound to double primitives.

    Essentially I have a grid with mostly zeros and I would rather not see them unless a non-zero value is supplied.

    I looked over some of the default cell viewers but couldnt find what I was looking for.

    Do you support something similar to the Format and Parse events in standard binding for manipulating the bound value's appearance? 

     

  •  10-07-2008, 3:22 PM Post no. 15955 in reply to 15949

    Re: Custom Cell Formatting

    You can use the FormatSpecifier property on Column to specify the format with which you want the cell value to be displayed.

    e.g. :

        gridControl1.Columns[ "Double Column" ].FormatSpecifier = "#.##";


    André
    Software Developer and Tech Support
    Xceed Software Inc.
  •  10-10-2008, 9:28 AM Post no. 16017 in reply to 15955

    Re: Custom Cell Formatting

    Thanks for the response.

    Yes that works correctly for values of zero (0.00 is now blank), but now I lose 2 decimal place precision for non-zero currency values (2.00 now becomes 2).

    Is there a way to achieve a finer level of formatting logic than a single format specifier property?

    Or perhaps there is a format that will solve both my scenarios? Im not finding much in the documentation on the specific formats.

    Thanks

     

     

  •  10-10-2008, 1:59 PM Post no. 16022 in reply to 16017

    Re: Custom Cell Formatting

    Got It. Implementing an IFormatProvider provides what I am looking for.

    gridControl1.Columns["Test Column"].FormatProvider = new ExampleNumberFormatter();

     

    public class ExampleNumberFormatter : IFormatProvider, ICustomFormatter {

    public string Format(string fmt, object arg, IFormatProvider formatProvider){

    ...

    }

    }

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.