Calculated column in Datagridview

  • Thread starter Thread starter BAndersson
  • Start date Start date
B

BAndersson

Guest
I have an unbound column in a datagridview which uses two other columns to calculate its value. I have tried the following code:

ForEachrow AsDataGridViewRowInDataGridView1.Rows

Ifrow.Cells("Weight1").Value IsNotNothingAndrow.Cells("Weight2").Value IsNotNothingThen


row.Cells("SumWeights").Value = row.Cells("Weight1").Value + row.Cells("Weight2").Value


EndIf

but I get an error System.InvalidCastException: 'Operator '+' is not defined for type 'DBNull' and type 'DBNull'.'


Can anyone suggest what I am doing wrong?




Continue reading...
 
Back
Top