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 Udo,
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.
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