Home Forums WinForms controls Xceed Grid for WinForms How to rebind a DataTable to Xceed.Grid

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

    Hello all, new user here. 

    In code, I create a table, then bind it to the grid.

      DataTable table = new DataTable(“Path”);
      table.Columns.Add(“ID”, typeof(int));
      table.Columns.Add(“Name”, typeof(string));
     //…

      grd.SetDataBinding(table, null);

    // Programmatically add rows to table…

      table.Rows.Add(…); 

    This works the first time I call it, but after some data changes in the tool, calling the above code again errors at the SetDataBinding with:

     Object reference not set to an instance of an object.

    I am using a FixedFooterRow, but otherwise, it’s a rather boring grid.

    Imported from legacy forums. Posted by Dustin (had 1014 views)

    User (Old forums)
    Member
    Post count: 23064

    To fix my problem, all that was needed was to Clear the FixedFooterRows:

      dg.FixedFooterRows.Clear();
      dg.SetDataBinding(table, null);

    It’d be nice if the error was more specific.

     

     

     

    Imported from legacy forums. Posted by Dustin (had 749 views)

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