How to add the values in several columns and give the result in another column of same row
'Program is to How to add the values in several columns and
' give the result in another column of same row.
' If the DataGridView control has 4 columns and we want to add the values
' in the first three columns and display the Total in the last column
' of the same row.
' So, whenever a value in the column is changed the Total
' should get recalculated.
Private Sub DataGridView1_CellValidated(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValidated
Dim cy As Integer
'Get the current cell's Row
cy = DataGridView1.CurrentCellAddress.Y
' Add the first three columns (0,1,2) and display it in the
' fourth column
DataGridView1.Item(3, cy).Value = Val(DataGridView1.Item(0, cy).Value) + Val(DataGridView1.Item(1, cy).Value) + Val(DataGridView1.Item(2, cy).Value)