please I want to send records in datagridbiew 1 to another datagridview2
is like if a user click on a button it Shud be able to send maybe 5 records in datagridview1 to datagridview2 at the Same time
please I need your help.

Recommended Answers

All 3 Replies

You could use a module to send data to both datagridviews

Hello prince,

Please provide your code and highlight where you are facing problem or what error you are getting. please be specific.

Hi Prince,

If I understand you correctly maybe this link can help you:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/72bee14b-53d7-4a62-a6a0-381aeb8ef14b/copy-datagridview1-data-to-datagridview2

https://social.msdn.microsoft.com/Forums/en-US/8c4c8eda-10b5-4393-84c8-418ada34ae98/copy-selected-rowscells-from-one-datagridview-to-another

or using this sample code:

Public Class Form1

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    initializeDgv1()
    initializeDgv2()
End Sub

Dim tableOfDgv1, tableOfDgv2
Private Sub initializeDgv1()
    tableOfDgv1 = New DataTable()
    tableOfDgv1.Columns.Add("Dgv1_Column1")
    tableOfDgv1.Columns.Add("Dgv1_Column2")
    dataGridView1.DataSource = tableOfDgv1
End Sub

Private Sub initializeDgv2()
    tableOfDgv2 = New DataTable()
    tableOfDgv2.Columns.Add("Dgv2_Column1")
    tableOfDgv2.Columns.Add("Dgv2_Column2")
    dataGridView2.DataSource = tableOfDgv2
End Sub

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    tableOfDgv2.Clear()
    Dim table1Value As DataRow
    For i As Integer = 0 To DataGridView1.Rows.Count - 2
        table1Value = tableOfDgv2.NewRow()
        table1Value("Dgv2_Column1") = DataGridView1.Rows(i).Cells("Dgv1_Column1").Value.ToString()
        table1Value("Dgv2_Column2") = DataGridView1.Rows(i).Cells("Dgv1_Column2").Value.ToString()
        tableOfDgv2.Rows.Add(table1Value)
    Next
    DataGridView2.DataSource = tableOfDgv2
End Sub

End Class

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.