Question DataGridView skip blank rows

abhit_kumar

Member
Joined
Aug 13, 2008
Messages
19
Programming Experience
Beginner
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 Prob 1.JPG
 
Back
Top