字符串格式-如果数字是整数,则隐藏小数点



我现在觉得自己很蠢,但我无法为我的数字创建简单的格式。我正在使用WPF的DevExpress 22.2控件。网格内部是列,其中只有数字。这些数字有时有小数部分,有时没有。

例子:96年,00000年120年,65000年12003

我需要整数像这样显示'96',实数像这样显示'120,65'和'23,12003'。

我的WPF列代码:

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

这种格式总是返回小数点后2位的数字(在我的区域性中是逗号)。

我的结果:'96,00' '120,65' '23,12'

请问,有人能帮帮我吗?谢谢你。

Ok…刚问了一分钟就找到了答案…虚惊一场,对不起。

DisplayFormatString ="#,0。# # # # # #">