private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
// Ensure the event is triggered by changes in Column1 or Column2
if (e.ColumnIndex == dataGridView1.Columns[“Price”].Index || e.ColumnIndex == dataGridView1.Columns[“Qty”].Index)
{
// Get the current row
DataGridViewRow row = dataGridView1.Rows[e.RowIndex];
// Get the values from Column1 and Column2
double value1 = Convert.ToDouble(row.Cells["Qty"].Value);
double value2 = Convert.ToDouble(row.Cells["Price"].Value);
// Calculate the result
double result = value1 * value2;
// Set the result in the ResultColumn
row.Cells["Total"].Value = result;
}
1