Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
i have two datagridview tables dt1 and dt2,i want to combine the value dt1 and dt2 and put the combined value to new datagridview dt3.
for ex dt1=0000,dt2=02 then dt3=0000,02
if first value for dt1 is 0000 and dt2 is 02,the value in dt3 should be as 0000,02
i tried this but not working
For c = 0 To DataDataGridView1.Rows.Count - 1
For t = 0 To DataDataGridView2.Rows.Count - 1
DataGridView3.Rows.Add(DataDataGridView1.Rows(c).Cells(0).Value)
Next
Next

thanks in advance

What I have tried:

C#
For c = 0 To DataDataGridView1.Rows.Count - 1
    For t = 0 To DataDataGridView2.Rows.Count - 1
        DataGridView3.Rows.Add(DataDataGridView1.Rows(c).Cells(0).Value)
    Next
Next
Posted
Updated 17-Nov-16 3:17am

1 solution

Try something like this:
VB.NET
For c = 0 To DataDataGridView1.Rows.Count - 1
    Dim value1 As Object = DataDataGridView1.Rows(c).Cells(0).Value
    For t = 0 To DataDataGridView2.Rows.Count - 1
        Dim value2 As Object = DataDataGridView2.Rows(t).Cells(0).Value
        DataGridView3.Rows.Add(value1, value2)
    Next
Next

DataGridViewRowCollection.Add Method (Object[]) (System.Windows.Forms)[^]
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900