I have a datagridveiw with 6 differnet columns. I got 2 columns with the header names, "In" and "Out".

So my question is, how can i get the sum of each showing in a seperate textbox. Not by the # of columns there are but by the name of the header?
Example:

Textbox1.text= the sum of the column named "In"

Textbox2.text= the sum of the column named "Out"

Recommended Answers

All 2 Replies

Go through the rows , pick and add your desired cell values.

Dim x As Double = 0.0#
Dim y As Double = 0.0#

For i As Integer = 0 To DataGridView1.Rows.Count - 1
    x += CDbl(DataGridView1.Rows(i).Cells(4).Value)
    y += CDbl(DataGridView1.Rows(i).Cells(5).Value)
Next

TextBox1.Text = x
TextBox2.Text = y

Please continue with any help here, where the OP has already asked the question and a thread is in full swing...

Closing this one.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.