2

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

Besty
  • 55
  • 1
  • 5

2 Answers2

2

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";
Ivan Stoev
  • 195,425
  • 15
  • 312
  • 343
0

You need to change the current culture.

Check this question: String format currency

Community
  • 1
  • 1
Jerry
  • 4,258
  • 3
  • 31
  • 58
  • Thank you that is very helpful and works with my other variables: but im not sure how to do this for a DataGridView – Besty Mar 20 '16 at 16:54