Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I made a programmed to Transfer Employee's To Other Company Therefore I used Two DataGridView, In First DataGridView Component I Bind it with database and Add One Another columns, and it's a checkboxcolumn,
Now I want to Copy/Transfer Rows From One DataGridView1 To DataGridView2 When I Tick or Checked; ChecekColumnBox in First DataGridView1.
Posted
Updated 29-Jan-19 9:22am

1 solution

I got It........
I made New and success in datagridview1 rows copy to another datagridview2 in vb.net

below is a code on button12_click Event

VB
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click

        Dim c, t As Integer
        dg2.Columns.Clear()

        For t = 0 To dg1.Columns.Count - 1
            dg2.Columns.Add(dg1.Columns(t).Clone())
        Next

        For c = 0 To dg1.Rows.Count - 1
       
     If dg1.Rows(c).Cells(4).Value = True Then
                dg2.Rows.Add(dg1.Rows(c).Cells(0).Value, dg1.Rows(c).Cells(1).Value)
                dg2.Columns(2).Visible = False
                dg2.Columns(3).Visible = False
       
     End If

        Next
    End Sub

Use it..............

[edit]code blocks added[/edit]
 
Share this answer
 
v2
Comments
Nelek 13-Feb-13 3:10am    
Self-solved in the same minute of the question.... that was fast :)
Remoddn 13-Feb-13 3:29am    
Yes! Nelek Because of I m trying or finding this question's answer but unable to find therefore today I create and find solution so; I post both of them, i.e. question's with answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900