Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a little problem with copying selected rows in datagridview to another datagridview on this code that I have I dont get values inside copied rows

C#
foreach (DataGridViewColumn c in dg1.Columns)
            {
                dg.Columns.Add(c.Clone() as DataGridViewColumn);
            }

            foreach (DataGridViewRow r in dg1.SelectedRows)
            {
                int index = dg.Rows.Add(r.Clone() as DataGridViewRow);
                foreach (DataGridViewCell o in r.Cells)
                {
                    dg.Rows[index].Cells[o.ColumnIndex].Value = o.Value;
                }
            }
Posted

1 solution

my datagridview was set to true in VirtualMode, and thats why copied values were blank, now it works.
 
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