C# DataGridView £ 而不是 $

C# DataGridView £ instead of $

我正在使用 DataGridView 显示数据库中的数据。我正在尝试格式化一列以显示为带有 £ 符号而不是 $.

的货币

我目前正在使用此代码:

this.dgvPRL.Columns[4].DefaultCellStyle.Format = "c";

但是它显示的是 $ 而不是 £。

谢谢

你需要改变当前的文化。

检查这个问题: String format currency

如果您想使用当前的文化货币设置,但更改该数据网格视图列的符号,除了 Format 属性 您还需要设置 DataGridViewCellStyle.FormatProvider 属性 像这样(确保包含 using System.Globalization;):

var info = (CultureInfo)CultureInfo.CurrentUICulture.Clone();
info.NumberFormat.CurrencySymbol = "£";
this.dgvPRL.Columns[4].DefaultCellStyle.FormatProvider = info;
this.dgvPRL.Columns[4].DefaultCellStyle.Format = "c";