DataGridView: FormatProvider in DefaultCellStyle cannot be updates

0
0

Hi,

in some use case scenarios, we set the Format of DataGridColumns to “C2”, so they are displayed as a currency with the corresponding currency symbol. However in some cases we need to use a different currency symbol than that of the CurrentCulture of the application.

In WebGui we just cloned the CultureInfo of the CurrentCulture, adjusted the CurrencySymbol and set the cloned CultureInfo object as a FormatProvider of the DefaultCellStyle of the corresponding DataGridColumn.

In WiseJ this approach does not seem to work. Please find a sample attached. The CurrencySymbol does not get updated. If you step through the code using the debugger you can see, that the DefaultCellStyle is simply ignoring the new setting.

Can you confirm if this is a bug or if there is another way to achieve this?

Thanks and best regards

Markus

  • You must to post comments
0
0

Hi Markus,

You can use something like this with Wisej, copying the NumberFormatInfo instance instead of the entire culture:

System.Globalization.NumberFormatInfo ci = (System.Globalization.NumberFormatInfo)Application.CurrentCulture.NumberFormat.Clone();
ci.CurrencySymbol = ““;

foreach (Wisej.Web.DataGridViewColumn gc in dataGridView1.Columns)
{
if (gc.HasDefaultCellStyle)
{
gc.DefaultCellStyle.FormatProvider = ci;
}
}

dataGridView1.DataSource = tb;

 

Let me know if this works for you!

Best,

Levie

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.