wpfstring-formattingdevexpress-wpf

String Format - hide decimal points if number is round


I feel stupid now, but I am unable to create simple format to my numbers. I am using DevExpress 22.2 controls for WPF. Inside a grid is column, in which is only numbers. Sometimes the numbers have decimal part, and sometimes there is none.

Examples: 96,00000 120,65000 23,12003

I need the round number to be displayed like this '96' and the real number like this '120,65' and '23,12003'.

My WPF code for column:

<dxg:GridColumn Header="Počet/Objem" FieldName="Volume" BestFitModeOnSourceChange="AllRows" BestFitMode="AllRows" AllowBestFit="True">
    <dxg:GridColumn.CellTemplate>
        <DataTemplate>
            <dxe:TextEdit Name="PART_Editor" 
                          HorizontalContentAlignment="Right" MaskType="Numeric" 
                          DisplayFormatString="n"
                          ShowBorder="False" 
                          dxe:NumericMaskOptions.AlwaysShowDecimalSeparator="False"/>
        </DataTemplate>
    </dxg:GridColumn.CellTemplate>
</dxg:GridColumn>

This formating always return numbers with 2 digits after decimal point (comma in my culture).

My resuls: '96,00' '120,65' '23,12'

Please, can someone help me? Thank you.


Solution

  • Ok ... found answer just a minute after asking ... false alarm and sorry.

    DisplayFormatString="#,0.######"