Dear All,

following is the code at button event which copy data from one DGV (dgvAccesList) to another DGV (dgvProbReport) and its working properly. Its paste data to 3rd and 4th column of destination DGV.

But the problem is that, if at source DGV first column and second column have data..lets say up to 2 rows..then its copied data starting from 3rd row..for the 3rd and 4th column..which is incorrect..its should be always start with first row of third and fourth column.


Please see the attached image for more clarity.


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


For Each dgvRow As DataGridViewRow In dgvAccesList.SelectedRows
Dim dgvNewRow As New DataGridViewRow
dgvNewRow.CreateCells(Inward.dgvProbReport)

dgvNewRow.Cells(2).Value = dgvRow.Cells("ID").Value
dgvNewRow.Cells(3).Value = dgvRow.Cells("Accessories").Value

Inward.dgvProbReport.Rows.Add(dgvNewRow)
Next


End Sub

Please help me so that i can resolve this problem.

Regards,
AKM

Recommended Answers

All 2 Replies

If you work with the selected rows, only those selected are used.

Try changing the loop to

For Each dgvRow As DataGridViewRow In dgvAccesList.Rows

Hope this helps

If you work with the selected rows, only those selected are used.

Try changing the loop to

For Each dgvRow As DataGridViewRow In dgvAccesList.Rows

Hope this helps

Its print all data of dgv....its not work at all

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.