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

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

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

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

Hi

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

txtTotalAmount.Text = (total + total1).ToString

HTH

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.