Well, you seem to know how to get the cell from a
DataGridView
... The problem is that a cell holds an
Object
. And you can't add
Object
s.
If you're sure cells (2, 3) and (3, 5) always exist and are always filled with a numeric type you could simply do the following:
Dim var As Decimal = CDec(dgvMyGrid.Item(2, 3).Value) + CDec(dgvMyGrid.Item(3, 5).Value)
txtMyTextBox.Text = var.ToString
If the values are
Integer
s you could use
CInt
. It would be safe to check if the cell exist though...
If dgvMyGrid.Item(2, 3) IsNot Nothing AndAlso dgvMyGrid.Item(3, 5) IsNot Nothing Then
End If
Hope that helps.