Besty
Besty

Reputation: 55

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

Upvotes: 2

Views: 58

Answers (2)

Ivan Stoev
Ivan Stoev

Reputation: 205629

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";

Upvotes: 2

Jerry
Jerry

Reputation: 4408

You need to change the current culture.

Check this question: String format currency

Upvotes: 0

Related Questions