Here is my example
I want to remove $
but the format still the same? How can I possibly do this?
Here is my code in my datagridview
dataGridView1.Columns["Amount"].DefaultCellStyle.Format = "c2";
expected output
(2,138,870,900.11)
19,921,759.23
..and so on
If you still want parenthesis for negatives, try:
dataGridView1.Columns["Amount"].DefaultCellStyle.Format = "#,0.00;(#,0.00)";
Alternatively:
var provider = (CultureInfo)CultureInfo.CurrentCulture.Clone();
provider.NumberFormat.NumberNegativePattern = 0;
dataGridView1.Columns["Amount"].DefaultCellStyle.FormatProvider = provider;
dataGridView1.Columns["Amount"].DefaultCellStyle.Format = "N";
or:
var provider = (CultureInfo)CultureInfo.CurrentCulture.Clone();
provider.NumberFormat.CurrencySymbol = "";
dataGridView1.Columns["Amount"].DefaultCellStyle.FormatProvider = provider;
dataGridView1.Columns["Amount"].DefaultCellStyle.Format = "C";
but these solutions depend on your current culture info (which might be a good thing, but we don't know what culture you use, so we might not know which properties you need to alter).
Instead of setting the FormatProvider
property on each column, you can also do:
// change 'provider' clone as before
Thread.CurrentThread.CurrentCulture = provider;
but that will affect all parts of your application (for the relevant thread at least).