Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: 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
0 OriginalGriff 220
1 ProgramFOX 120
2 Richard MacCutchan 100
3 kbrandwijk 90
4 ChauhanAjay 80
0 Sergey Alexandrovich Kryukov 9,050
1 OriginalGriff 8,151
2 CPallini 2,613
3 Richard MacCutchan 2,221
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 15 Nov 2012
Copyright © CodeProject, 1999-2014
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