An object-oriented programming language developed by Microsoft that can be used in .NET.
Hi @Hobbyist_programmer ,
Here is a simple example you can refer to.
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim dataTable As DataTable = New DataTable
dataTable.Columns.Add("ID")
dataTable.Columns.Add("Name")
dataTable.Columns.Add("Total")
dataTable.Rows.Add(1, "A", 10)
dataTable.Rows.Add(2, "B", 11)
dataTable.Rows.Add(3, "C", 12)
DataGridView1.DataSource = dataTable
End Sub
Private Sub DataGridView1_CellValueChanged(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
Dim count As Integer = 0
If e.ColumnIndex = 2 AndAlso e.RowIndex >= 0 Then
Dim lst = Me.DataGridView1.Rows.Cast(Of DataGridViewRow)().Select(Function(row) row.Cells.Item(2).Value)
For Each value In lst
If value IsNot Nothing Then
count += Convert.ToInt32(value)
End If
Next
DataGridView1.Columns.Item(2).HeaderText = count
End If
End Sub
Besides, if I have any misunderstanding, please provide more details here.
Best Regards,
Xingyu Zhao
*
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.