Home Forums WinForms controls Xceed Grid for WinForms Adding Rows to Unbound Grid

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #14084 |

    I’m trying to add rows to an unbound grid and the logic I have almost works, but it’s missing something. For example, if I select 5 rows and try to add them to another grid, it only adds 4. Here is my code:
    <b>
    gridControl1.BeginInit();

    foreach (Xceed.Grid.DataRow myRow in gridControl2.SelectedRows)
    {
    // add to grid
    Xceed.Grid.DataRow row = gridControl1.DataRows.AddNew();
    row.Cells[“TEST_NAME”].Value = myRow.Cells[“TEST_NAME”].Value;
    row.Cells[“ALIQUOT_NAME”].Value = myRow.Cells[“ALIQUOT_NAME”].Value;
    row.Cells[“TEST_ID”].Value = myRow.Cells[“TEST_ID”].Value.ToString();
    }
    gridControl1.EndInit();
    </b>

    If anyone sees anything wrong here please let me know.

    Thanks in advance.

    Imported from legacy forums. Posted by Nathan (had 1897 views)

    User (Old forums)
    Member
    Post count: 23064

    This made it work:

    <b>
    foreach (Xceed.Grid.DataRow myRow in gridControl2.SelectedRows)
    {
    // add to grid
    Xceed.Grid.DataRow row = gridControl1.DataRows.AddNew();
    row.Cells[“TEST_NAME”].Value = myRow.Cells[“TEST_NAME”].Value;
    row.Cells[“ALIQUOT_NAME”].Value = myRow.Cells[“ALIQUOT_NAME”].Value;
    row.Cells[“TEST_ID”].Value = myRow.Cells[“TEST_ID”].Value.ToString();
    row.EndEdit();
    }
    </b>

    Imported from legacy forums. Posted by Nathan (had 2979 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.