Search code examples
c#datagridviewcurrency

C# DataGridView £ instead of $


I am using a DataGridView to display data from a database. I am trying to format a column to display as a currency with a £ symbol rather than a $.

I am currently using this code:

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

however it displays with a $ not £.

Thank you


Solution

  • If you want to use the current culture currency settings, but change the symbol for that data grid view column, in addition to Format property you need to set DataGridViewCellStyle.FormatProvider property like this (make sure to include 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";