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
thanks
This really has nothing to do with the grid. If you add a new row to the data source and the grid doesn't display that row, it's because the data source did not notify the grid that a new row was added.
The grid's DataSource should be either an IBindingList or an IList. But the IList interface is limited and doesn't have full support for all of the notifications needed to handle data binding. So you are better off using an IBindingList if you can.
The structure that is returned from a LNQtoSQL call simply isn't designed for DataBinding in Windows Forms.
The best solution I have found for using LNQtoSQL is to copy the returned data into a DataTable and bind the grid to that DataTable.
hey , i dont have such option ,
As stated above : the problem is when a pass an linq2sql table as a datasourse to a grid, after addining new row to the datasource , the grid is not effected !!!
the workaround i do is (not good but works):
private void BtnAdd_Click(object sender, System.EventArgs e) {
....
PerformAddOperation( ... );
//save display layout and restore it after the assignment to the datasource
MemoryStream stream = new MemoryStream(); GrdData.DisplayLayout.Save(stream);
WinGrid.DataSource = Linq2sqlTable.ToList(); WinGrid.Refresh(); stream.Position = 0; WinGrid.DisplayLayout.Load(stream); stream.Close(); stream.Dispose(); txtType.Clear(); }
Hello zubimenta,
Could you please attach if possible a small sample project reproducing this issue for us, I will be happy to take a look at it.
Hey, same problem with add and remove rows in the grid. Tried both of your suggestion:
the first one: there is a method
linkDataTableObj.GetNewBindingList()
which returns IBindingList
no effect
the second suggestion, the same as Udo's,
The only change is :
the layout display resets, the row is not added