Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
235
Refreshing WinGrid in Windows Form App
posted

I am using Entity Framework to communicate with an SQLServer database and am using WinGrid to view the database records. To edit, add or delete a record, I call up a separate detail form. If I am editing or deleting a record, when the changes are made, the WinGrid reflects the changes immediately and the altered record appears in the grid (or disappears in the case of a delete). When adding an new record, however, the record is not visible in the grid after performing a "SaveChanges()" command to save the new record to the database. If the program is closed and then restarted, the record appears in the grid as it should. I have tried every refresh command I can think of on all of the components, including the grid, the bindingsource and the EF components and nothing works to show the new record in the grid.

Any suggestions?

 

Parents
No Data
Reply
  • 2549
    Verified Answer
    posted

    Hi Mike and Steve

    I figured it out.
    It has nothing to do with the UltraGrid, as Steve already confirmed that it also doesn't work with GridView.

    I searched for a while and came up with the following solution:

    grdAccounts.DataSource = _dataContext.tblAccount.Execute(MergeOption.AppendOnly);
    grdAccounts.Refresh();

    You need to call this if you bind the first time and after you added new rows.
    For deletes and updates refreshing the grid is sufficient.

    Hope it helps.

    cheers
    Andy

Children