Hi,
I am calculating the datagridview column2 based on column1 value which is a input field.
I am doing this on datagridview cellLeave event. But firsttime When I enter some numeric value on column1 and tab out I am not getting the value of column1 but getting that in second time.
How could I get the value as soon as I tab out.
Here is my code.
private
void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView1.Rows[e.RowIndex].IsNewRow) { return; }
if (e.ColumnIndex != 0)
{
return;
}
else
{
if (!string.IsNullOrEmpty(dataGridView1[e.ColumnIndex, e.RowIndex].Value.ToString()))
{
decimal val = Convert.ToDecimal(dataGridView1[e.ColumnIndex, e.RowIndex].Value.ToString());
decimalval1 = Convert.ToDecimal(dataGridView1[2, e.RowIndex].Value.ToString());
decimalval2 = Convert.ToDecimal(dataGridView1[3, e.RowIndex].Value.ToString());
decimalval3 = val * (val1 + val2);
dataGridView1[1, e.RowIndex].Value = val3;
}
}
}
Please help.
Thanks!!