Home Forums WinForms controls Xceed Grid for WinForms Custom Cell Formatting

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #16538 |

    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? 

     

    Imported from legacy forums. Posted by Patrick (had 1005 views)

    User (Old forums)
    Member
    Post count: 23064

    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 = “#.##”;

    Imported from legacy forums. Posted by André (had 362 views)

    User (Old forums)
    Member
    Post count: 23064

    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

     

     

    Imported from legacy forums. Posted by Patrick (had 474 views)

    User (Old forums)
    Member
    Post count: 23064

    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){

    }

    }

    Imported from legacy forums. Posted by Patrick (had 1283 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.