I just need a little help here, I wanted to copy the rows in current form's datagridview to another form's datagridview.

Here is my example rows in datagridview1 in current row

ID | ProID | Name
1  | 1     | Shirt
2  | 1     | Shoes
3  | 2     | Pants
4  | 2     | Cap

What I want is when I selected shirt and click the button all rows with the same ProID as the selected row will be copied to another form's datagridview.

Here is my code but it only transfer the selected row and not all rows with the same ProID as the selected row. I don't have an idea on how to loop all rows to be copied.

Dim i As Integer = Promotion.DataGridView1.Rows.Count + 1
            Promotion.DataGridView1.Rows.Add(i, DataGridView1.CurrentRow.Cells("PLU").Value, DataGridView1.CurrentRow.Cells("Barcode").Value, DataGridView1.CurrentRow.Cells("ItemName").Value, DataGridView1.CurrentRow.Cells("ItemPrice").Value, DataGridView1.CurrentRow.Cells("Description").Value)

Recommended Answers

All 4 Replies

I wonder if your code would ever compile and it certainly does not use two datagridviews.
Here is an example on how to loop through datagridviewrows

Actualy it compiled and by the way I already solved my problem, the 1st datagridview was data bounded so I just decided to get the values to be transfered in 2nd datagridview in database instead of the 1st datagridview... Anyway thank you so much for the reply.. I just wonder why it tooks so many hours before we get a reply from this website knowing that a lot of professional programmers are navigating this forum.

Perhaps many have a weekend? Or are on holyday? Perhaps some have other things to do? We are all here on a free basis you know. We are certainly not paid for the services. I would even refuse to get paid for it.

Can I hire you to code POS Hardware for our project? If you're interested please add me in facebook. fb.com/yvrej17

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.