Home Forums WinForms controls Xceed Grid for WinForms Adding rows to a bounded grid

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

    I have a grid bounded to a DataTable. I would like to add a new row to the grid, but I also would like the changes to be reflected in a DataTable. How should I do it??? I’ve tried doing something like this:

    DataRow row = grid.DataRows.AddNew()

    for(int I = 0; i < row.Cells.Count; i++)
    row.Cells[i] = someValue;

    row.EndEdit();

    but after that I don’t see any changes – neither in grid nor in DataTable.

    Thanks for any help!

    Imported from legacy forums. Posted by styko (had 1419 views)

    User (Old forums)
    Member
    Post count: 23064

    Hmm… The syntax doesn’t look quite right to me.

    DataRow newrow = grid.DataRows.AddNew().BeginEdit();

    for loop

    newrow.EndEdit();

    Make sure you ‘i’ value stays lower case in your loop 😉

    Imported from legacy forums. Posted by Buggi (had 291 views)

    User (Old forums)
    Member
    Post count: 23064

    >DataRow newrow = grid.DataRows.AddNew().BeginEdit();

    BeginEdit() returns void… But I modified my previous code:

    DataRow newrow = grid.DataRows.AddNew();
    newrow.BeginEdit();

    for loop

    newrow.EndEdit();

    and it is still not working.

    >Make sure you ‘i’ value stays lower case in your loop
    ‘i’ stays lowercase all the time in my code. The reason it is uppercase in my post is that I wrote my post using Word because I wanted it to check my spelling. So it’s not a meter of i variable.

    Imported from legacy forums. Posted by styko (had 422 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi guys. All you have to do is add a new row to the DataTable. If it’s bound to the grid, it will show up automagically.

    Imported from legacy forums. Posted by MBonafe (had 313 views)

    User (Old forums)
    Member
    Post count: 23064

    Or use an InsertionRow

    Imported from legacy forums. Posted by MBonafe (had 5266 views)

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