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

Recommended Answers

All 7 Replies

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

Is it giving you the desired output or is there a question here?

yes i got what i want.
thnks

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.