Click here to Skip to main content
12,405,868 members (69,452 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# C#4.0
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

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 14-Nov-12 20:14pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

my datagridview was set to true in VirtualMode, and thats why copied values were blank, now it works.
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 15 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100