0

I want to get the total sum of the amount column. How can I display the total sum to the textbox total? Any possible way to do it? Please help. Thanks!

Attachments ScreenShot.png 34.25 KB
5
Contributors
7
Replies
34
Views
4 Years
Discussion Span
Last Post by Ann95
0

Try :

        Dim temp As Long = 0
        For i = 0 To DataGridView1.Rows.Count - 1
            temp = temp + DataGridView1.Item(6, i).Value 'Column 6 is Amount
        Next
        Total.Text = temp
0

If the source for the DataGrid is a database you should be able to do it with a single query. If you provide more detail perhaps I can suggest something.

0

the datagrid is bound

You can use SUM function to get total amount.
select sum(amount) as TotalAmount from TableName

0
    Label.Text = "Total Mount = " & ((From NetMount As DataGridViewRow In DataGridView1.Rows Where NetMoun.Cells(6).FormattedValue.ToString <> "" Select CInt(NetMoun.Cells(6).FormattedValue)).Sum)
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.