private void Gv_CellEndEdit(object sender, DataGridViewCellEventArgs e) { //do your checks to see RowIndex is not -1 and other good stuffs //var row = gv.Rows[e.RowIndex]; try { int rowIdx = e.RowIndex; int colIdx = e.ColumnIndex - 1; DataGridView senderGrid = (DataGridView)sender; decimal packingSize = 0; decimal.TryParse(dtOrderItem.Rows[rowIdx][ConstColumns.PACKING_SIZE].ToString(), out packingSize); switch (senderGrid.Columns[e.ColumnIndex].Name) { case "qty": dtOrderItem.Rows[rowIdx][ConstColumns.WGH] = MyExtension.ToInt32(dtOrderItem.Rows[rowIdx][ConstColumns.QTY].ToString()) * packingSize; break; case "wgh": if (packingSize == 0) { break; } dtOrderItem.Rows[rowIdx][ConstColumns.QTY] = RoundQty(MyExtension.ToDecimal(dtOrderItem.Rows[rowIdx][ConstColumns.WGH].ToString()) / packingSize); break; } dtOrderItem.AcceptChanges(); gv.Refresh(); //row.Cells[e.ColumnIndex].OwningColumn.Name ##getName } catch (Exception) { throw; } }