0

hi, I have dgv1 that contains amount column, and dgv2 that also have amount aolumn.
I have following code to sum total vlaues of dgv1.
but i want display both column vlaues from both dgv in to single textbox.
how can i do this?

Dim total As Integer
        For Each row As DataGridViewRow In ReportDataGridView.Rows()
            total += row.Cells(6).Value
        Next
        txtTotalAmount.Text = total
2
Contributors
7
Replies
12
Views
2 Years
Discussion Span
Last Post by Satyam_1
0

Hi

Use the same code to grab the total for the amount column in your second data grid view and then add both totals together and assign to your text box.

HTH

0

how can i add both totals together and assign it to single textbox.

0

here is what i get the total of 2 dgv in two different textboxs , but I want the total in single textbox.

here is the code.

Dim total As Integer
            For Each row As DataGridViewRow In PatientDetailsDataGridView.Rows()
                total += row.Cells(8).Value
            Next
            txtTotalAmount.Text = total

Dim total1 As Integer
            For Each row As DataGridViewRow In FollowUpRegisterDataGridView.Rows()
                total1 += row.Cells(8).Value
            Next
            TextBox1.Text = total1
0

Hi

Add total and total1 together and assign to your text box:

txtTotalAmount.Text = (total + total1).ToString

HTH

0

Hi so my code is:-

Dim total As Integer
        For Each row As DataGridViewRow In PatientDetailsDataGridView.Rows()
            total += row.Cells(8).Value
        Next

        Dim total1 As Integer
        For Each row As DataGridViewRow In FollowUpRegisterDataGridView.Rows()
            total1 += row.Cells(8).Value
        Next
        txtTotalAmount.Text = (total + total1).ToString
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.