Hi @Richard Neider ,
Use 'DataGridView1.AllowUserToAddRows = False' to prevent users from adding new rows.
You can use the following code to sum the numbers.
I put it in the CellEnter event to trigger the sum every time the cell is clicked.
Private Sub DataGridView1_CellEnter(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellEnter
For Each ln As DataGridViewRow In DataGridView1.Rows
ln.Cells(7).Value = 2 * (Convert.ToInt32(ln.Cells(1).Value) + Convert.ToInt32(ln.Cells(2).Value) + Convert.ToInt32(ln.Cells(3).Value) + Convert.ToInt32(ln.Cells(4).Value) + Convert.ToInt32(ln.Cells(5).Value) + Convert.ToInt32(ln.Cells(6).Value))
Next
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
DataGridView1.AllowUserToAddRows = False
End Sub
Best Regards.
Jiachen Li
----------
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.