I have two grids, Grid1 and Grid2.
I drag a row (or more rows) from Grid1 to Grid2. My business logic takes datasource of Grid2 and adds correct objects to it. Then I rebind the datasource so that Grid2 shows the dragged rows.
This works, but only until Grid2 contains about eight messages. When this amount of rows is reached, Grid2 stops showing new rows. I double-checked my business logic and it does what it should: in the data source, there really are the new objects added.
So basically, datasource has 11 rows, but Grid2 only shows 8 of them. Any idea what can be wrong here? I tried setting Grid2.DisplayLayout.Bands[0].MaxRows = 10240 but it does not help.
Thank you very much.
First, thank you very much, Mike, for trying to help me!
Then: I was able to (partially) solve the problem. What was wrong:
I have a tree (Folders) and a grid (Messages of a Folder). Whenever I select a node on the tree, I rebind the treenode's list object to the grid. The data member of the tree is "Subfolders", the data member of the grid is "Messages".
Sometimes I need to change the Messages collection of a Folder, i.e. assign another collection to the folder, making the old Messages be forgotten (and waiting for GC). After I do that, I clear the databinding of the grid then rebind it with this line of code:
grid.SetDataBinding(folder, "Messages");
I'd suppose the grid would take the object folder and show its Messages data member. However, the grid seems to show the old Messages, and since any further change is affecting the new collection, the grid remains constant forever.
I fixed it by not changing Messages collection; instead, I empty it and fill it with new values. It's probably a better design anyway, so no problem there.
But I'd think it should work the other way too, am I right?
It sounds to me like you were binding the grid to a single row in the parent collection rather than binding to the child list under the folder that you want. I don't think that will work, and I'm frankly surprised that it works the first time you do it, if that's the case.My guess is that, if that works at all, the BindingSource is probably handling it.
In any case, the grid should be bound to the child list, which, if I understand you, is what you are doing now.