I am updating the cell format depending on the choice of combobox as soon as i choose value in combobox the cells where i want to change the format it starts flickering as shown in the video here
Here's the cell formating code:
private void dg_PDetails_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (cbo_PurchaseCurrency.Text == "Rupees Purchase")
{
var format = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();
format.CurrencySymbol = "₹ ";
dg_PDetails.Columns["AmountProduct"].DefaultCellStyle.FormatProvider = format;
dg_PDetails.Columns["AmountProduct"].DefaultCellStyle.Format = "c";
dg_PDetails.Columns["RateProduct"].DefaultCellStyle.FormatProvider = format;
dg_PDetails.Columns["RateProduct"].DefaultCellStyle.Format = "c";
}
else if (cbo_PurchaseCurrency.Text == "Dollar Purchase")
{
var formats = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();
formats.CurrencySymbol = "$ ";
dg_PDetails.Columns["AmountProduct"].DefaultCellStyle.FormatProvider = formats;
dg_PDetails.Columns["AmountProduct"].DefaultCellStyle.Format = "c";
dg_PDetails.Columns["RateProduct"].DefaultCellStyle.FormatProvider = formats;
dg_PDetails.Columns["RateProduct"].DefaultCellStyle.Format = "c";
}
String value = e.Value as string;
if ((value != null) && value.Equals(e.CellStyle.DataSourceNullValue))
{
e.Value = e.CellStyle.NullValue;
e.FormattingApplied = true;
}
}