Click here to Skip to main content
12,246,406 members (33,171 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB VB.NET
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 12-Feb-13 21:54pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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

below is a code on button12_click Event

Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
        Dim c, t As Integer
        For t = 0 To dg1.Columns.Count - 1
        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
    End Sub
Use it..............

[edit]code blocks added[/edit]
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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Dim c, t As Integer
     For t = 0 To DataGridView1.Columns.Count - 1
     For c = 0 To DataGridView1.Rows.Count - 1
         If Not IsDBNull(DataGridView1.Rows(c).Cells(3).Value) Then
             DataGridView2.Rows.Add(DataGridView1.Rows(c).Cells(0).Value, DataGridView1.Rows(c).Cells(1).Value, DataGridView1.Rows(c).Cells(2).Value, DataGridView1.Rows(c).Cells(3).Value)
             ' DataGridView2.Columns(2).Visible = False
             ' DataGridView2.Columns(3).Visible = False

         End If

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 19 Aug 2014
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100