Click here to Skip to main content
15,889,034 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi to all ..
I am struggling on how to populate my datagridview based on the other datagridview values. How can i get the values from a datagridview and put it to another datagridview?

Note that the value I want to put into another datagridview row is a column value from its original datagridview.
Posted
Comments
Animesh Datta 23-May-14 2:33am    
what have you tried so far ? put some code.
gggustafson 23-May-14 14:51pm    
row = 0
for column = 0 to column length
    target value [ row ] = source value [ column ]
    row++

end for
Emin Kokalari 24-May-14 13:01pm    
i think you should manipulate with your database ,... and then bind data from table of database to datagridview

if you are interested on this please reply maybe i help you.

1 solution

sir, below is an example to populate the "datagridview2" with "datagridview1"'s values

//For Adding Columns
for(int i=0;i<datagridview1.columns.count;i++)>
{
    datagridview2.Columns.Add(datagridview1.Columns[0].Name);
}

//For adding the rows
for(int j=0;j<datagridview1.rows.count;j++)>
{
    datagridview2.Rows.Add(datagridview1.Rows[j]);
}
 
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