For example: if I'm changing MRP
column, it should multiply that value with another column value called No_of_Units
and the result should be stored in column called Total
, Thanks in advance
You mean something like this ?
private void DataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == index of column MRP)
{
int value = (int)DataGridView1.Rows[e.RowIndex].Cells["NO_OF_UNITS"].Value * (int)DataGridView1.Rows[e.RowIndex].Cells["MRP"].Value;
DataGridView1.Rows[e.RowIndex].Cells["TARGET_COLUMN"].Value = value;
}
}
This answer is simplified, you might need some additional checks, like check on null values and that kind of stuff. But it should get you on your way.
In your comment you asked:
How to get the index of column MRP ?
Click on the datagrid. Find the property Columns and click on the little button in the list of columns, find the column MRP and copy the Name property. This could be MRP but it also be DataGridColumn1 or something.
Suppose the name property is 'MRP' than you can do:
if (e.ColumnIndex == MRP.ColumnIndex)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments