0

How do I pass DataGridView rows to a DataGridView on a different Form?

pos_receipt.PrintTable.Rows.Add(row.Cells("item_info").Value.ToString,
    row.Cells("Quantity").Value.ToString,
    row.Cells("Rate").Value.ToString,
    row.Cells("total").Value.ToString)

NB:
pos_receipt is the Form name where the DataGridView that I want to pass rows is located.

PrintTable is a data table

Jimi
  • 29,621
  • 8
  • 43
  • 61
Teddy Ted
  • 13
  • 4
  • 3
    Possible duplicate of [Passing data between forms](https://stackoverflow.com/questions/4587952/passing-data-between-forms) – Esko Apr 08 '19 at 08:41

1 Answers1

0

depends, if the form to which you want to pass the rows has been created in the form in which you are, the only thing you have to do is a public function in the destination form and call it from you origin form. ej:

    dim DestForm as new FormName()
    DestForm.GetRows(RowOfMyGrid)

And in the dest form

    Public sub GetRows(Row as datagridviewRow)
        myDataGrid.rows.add(Row)
    end sub

If it is the other way round, and you want to pass the rows from the destination to the origin, you would have to do it using events

JC M
  • 78
  • 6