我上網查遍了,由于我沒有太多經驗,所以找不到合適的解決方案。
如上所述,在我的資料庫中,我將有“大”值,其中最多有 9-10 位數字,并且我被要求將它們格式化為例如,而不是 23456789 -> 23,456,789.00,并像這樣顯示它們資料網格。
這就是我填充 DataGrid 的方式
probaDataContext proba = new probaDataContext();
public MainWindow()
{
InitializeComponent();
dgData.ItemsSource = proba.ProbaTabelas.ToList();
}
這是我的 XAML 代碼
我找到了一種將它們格式化為 23,456,789 的方法,但我仍然需要后面的那兩個數字,帶點。
<DataGrid Name="dgData" Margin="89,0,118,165" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="Numbernumber" Binding="{Binding cifra, StringFormat=\{0:N0\}}"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid
如果該值是一個整數,它們應該是 .00 ,如果一個值有像 23432.54 這樣的小數,它們應該看起來像 23,432.54。
uj5u.com熱心網友回復:
String.Format("{0:n}", 1234); // Output: 1,234.00
String.Format("{0:n0}", 9876); // No digits after the decimal point. Output: 9,876
所以我想改變這個
StringFormat=\{0:N0\}
對此
StringFormat=\{0:N\}
對你沒問題。
注意:有些文化習慣于,表示小數,而不是.小心。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/436204.html
上一篇:異步方法作為同步方法作業
