based on what I see it must be that you activeForm has not be initialized and is null. Without more code can't be certain.
S
smithjdst
@smithjdst
Posts
-
MDI Application ........... -
DataGridView Calculated Column update when move to new row C#after looking a little more, it may be better to use the cellvaluechanged event... sample (note this was tested only in C# win32.forms, and the column ValueTypes are strings):
private void dataGrid_CellValueChanged(object sender, DataGridViewCellEventArgs e) {
/*check Changing cell is "not" in the "Total" Column,
*would keep calling cell changed event, when the "Total" cell value changes*/
if ((e.RowIndex >= 0) && e.ColumnIndex != DataGrid.Columns["Total"].Index) {
//r = row of the changed Cell.
int r = e.RowIndex;//get values from cells in the same row int Qty = 0; int.TryParse((string)DataGrid\["Quantity", r\].Value, out Qty); double Price = 0D; double.TryParse((string)DataGrid\["UnitPrice", r\].Value, out Price); //Calculate Total, Change cell value in "Total" DataGrid\["Total", r\].Value = Price \* Qty; }
}
-
DataGridView Calculated Column update when move to new row C#Have you tried to update the values in the CellLeave event for your datagrid.