Hi,
I'm using a LINQ to SQL Object in an UltraWinGrid as DataSource. Almost everything works fine but there is one problem:
If You add a new line to the LINQ Object or if You remove an existing line from the LINQ object by code (not in the grid itself), the grid doesn't react. It doesn't remove removed line and doesn't show new lines. Event setting the DataSource of the grid to nothing and back to the LINQ Object doesn't help.
If I do the same with a DataTable as DataSource it works fine.
Is there a way to solve this problem?
Thanks,
Udo
HI, same problem, did you find any solution for this ... :) ?
Hi Udo,
If you are setting the DataSource to nothing and then back and that doesn't work, then something is seriously wrong. I don't see how the grid could possibly not be refreshing in that case. My guess is that your data source is not returning the correct data at that point, because I don't see how the grid could be showing rows that no longer exist after such a major change. Perhaps something in your data source is happening asynchronously so the code you have here is called before the change is actually being reflected?
Hi Mike,
I don't know how to coerce the returned data, so I've tried Your second suggestion. Unfortionately even the following code does'nt show any reaction:
Me.gridRooms.DataSource = NothingMe.gridRooms.Rows.Refresh(RefreshRow.ReloadData)Me.gridRooms.Rows.Refresh(RefreshRow.FireInitializeRow)Me.gridRooms.Rows.Refresh(RefreshRow.RefreshDisplay)Me.gridRooms.DataSource = Me._EventData.RoomsMe.gridRooms.Rows.Refresh(RefreshRow.ReloadData)Me.gridRooms.Rows.Refresh(RefreshRow.FireInitializeRow)Me.gridRooms.Rows.Refresh(RefreshRow.RefreshDisplay)
Any idea?
Thanks
The grid binds to two types of data sources: IList and IBindingList. The IBindingList interface is much more robust and provides notifications to the BindingManager when rows are added or removed. IList does not provide these notifications. So it sounds to me like the data source you are using an IList and not an IBindingList.
I'm not a LINQ to SQL expert - perhaps there is some way to coerce the returned data into a IBindingList or BindingList<>. If so, that would be the best way to handle this.
If not, then one alternative would be to notify the grid of the changes yourself. Any time you add or a remove a row, you can call grid.Rows.Refresh(ReloadData) and the grid will refresh the display based on the current data in the data source.