How can I copy specific rows from datagradview1 to datagradview2 which is data bound?

  • Thread starter Thread starter faysal13_13
  • Start date Start date
F

faysal13_13

Guest
How can I copy specific rows from datagradview1 to datagradview2 which is data bound? or what is code to can just copy specifi rows from dgv 1 to dgv 2 ......dgv2 have a date from sql and columns in dgv2 has a data property name



Public Class test3
Dim DTable1 As New DataTable
Dim DTable2 As New DataTable
Private Sub test3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim da As New SqlDataAdapter
DTable1.Clear()
da = New SqlDataAdapter("select cCDOE,cNAME from ITEMS", Con)
da.Fill(DTable1)
DataGridView1.DataSource = DTable1
'DataGridView1.DataSource = DTable1.Clone


Dim da1 As New SqlDataAdapter
DTable2.Clear()
da1 = New SqlDataAdapter("select qty,cost from ware", Con)
da1.Fill(DTable2)
DataGridView2.DataSource = DTable2
'DataGridView2.DataSource = DTable2.Clone

End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

DTable2 = DTable1.Clone
Dim dr As New System.Windows.Forms.DataGridViewRow
For Each dr In Me.DataGridView1.SelectedRows
Me.DataGridView2.Rows.Add(dr.Cells(0).Value, dr.Cells(1).Value)

Next

End Sub
End Class

Continue reading...
 
Back
Top