[英]How to always show three digits after the comma
Lets say i have a TextBox.可以说我有一个文本框。 When i write 0.5 i want it to Show it as 0.500 automatically.
当我写 0.5 时,我希望它自动显示为 0.500。
My Problem is that as soon as the Digits after the comma are 0 they get cut off.我的问题是,一旦逗号后面的数字为 0,它们就会被截断。
Example例子
0.5 -> 0.500 0.5 -> 0.500
0.51 -> 0.510 0.51 -> 0.510
The Change itself will happen in the LostFocus Event (Excel like calculation).更改本身将发生在 LostFocus 事件中(类似 Excel 的计算)。
I Need fixed 3 Digits.我需要固定 3 位数。
if you are in WPF, you can do it in XAML:如果您在 WPF 中,您可以在 XAML 中进行操作:
<TextBlock Text="{Binding Path=Length, StringFormat={}{0:#000}}" TextAlignment="Right"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.