I have a datagridview which displays my records in currency format. I set the DefaultCellStyle property permanently for the format BUT I have a particular column which I wanna display it values as an Integer.
The column i wanna change and what it displays:
[AreaCode]
15,00 €
25,00 €
60,00 €
My expectation:
[AreaCode]
15
25
60
And here is my code which isn't working:
private void dgv1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
var columnname = "AreaCode";
if (e.ColumnIndex == dgv1.Columns[columnname].Index)
{
//Get the datagridview cell
DataGridViewCell cell = dgv1.Rows[e.RowIndex].Cells[e.ColumnIndex];
if (cell != null)
{
this.dgv1.Columns["AreaCode"].DefaultCellStyle.Format = "D4";
}
}
}
Thnx in advance
Aucun commentaire:
Enregistrer un commentaire