We help IT Professionals succeed at work.
Get Started

Sum datagridview column into textbox

wiswalld
wiswalld asked
on
2,822 Views
Last Modified: 2009-06-29
I have a datagridview that holds values in columns (obviously). I want to take lest say column 27 and add all the values from that column and then divide them by the total number of rows in the datagridview. Another get an average for column 27 and put in a textbox on the form. This is the code I use to get the value in the column of the datagridview that I want to use.

 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        For Each row As DataGridViewRow In DataGridView1.Rows
            row.Cells(27).Value = row.Cells(26).Value - row.Cells(5).Value * 113 / row.Cells(4).Value
            Me.txtHandicap.Text = row.Cells(27).Value   <<< I want to put something here to do this.
        Next
    End Sub


Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008
Commented:
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE