To format a datagridview cell value in different format such as decimal to int or specially round format when colum is money data type in database .
to d0 that following code are neccessary .
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
decimal each = decimal.Parse( this.dataGridView1.Rows[i].Cells[2].Value.ToString());
decimal decimalcorund = decimal.Round(each, 2);
this.dataGridView1.Rows[i].Cells[2].Value = decimalcorund.ToString();
}
Here for looping affaged by total grid raw counting when every loop is run then i m taking my expected colum value in a decimal format then decimal round and feet with value celles again in datagridview .
No comments:
Post a Comment