Okay, you want to show calculation result in 5th cell when you enter values in 2nd and 3rd cell.
and if you enter values in 2nd, 3rd and 4th cell, you want to show calculation result in 6th cell only and not in 5th cell.
Am i right?
If this is what you want then try this code...
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Cells[2].Value != DBNull.Value && row.Cells[3].Value != DBNull.Value)
{
if(row.Cells[4].Value ==DBNull.Value)
{
float iWei = float.Parse(dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString());
float iPer = float.Parse(dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString());
dataGridView1.Rows[e.RowIndex].Cells[5].Value = (iWei * iPer) / 100;
dataGridView1.Rows[e.RowIndex].Cells[6].Value = null;
}
else
{
float iWei = float.Parse(dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString());
float iPer = float.Parse(dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString());
float iWas = float.Parse(dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString());
dataGridView1.Rows[e.RowIndex].Cells[6].Value = (iPer + iWas) * iWei;
dataGridView1.Rows[e.RowIndex].Cells[5].Value = null;
}
}
}
Let me know if this solve your problem...
Happy coding :)