I have an untrawingrid bound to a custom collection.
There is a DisplayLayout that we've serialized to XML that we share with users.
We want to add an unbound column after the user loads the grid's displaylayout. The sequence looks like this:
Dim stream As New IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(LayoutString))myGrid.LoadFromXml(stream, PropertyCategories.All)myGrid.DisplayLayout.LoadFromXml(stream, PropertyCategories.All)
which works wonderfully. All the default columns and sizing/sorting/etc. is persisted.
However, when we try to add a column, it winds up overwriting an existing column (being displayed, but not in the underlying object itself, it seems):
myGrid.DisplayLayout.Bands(0).Columns.Add("isLocked")
As soon as we do this and the grid is refreshed, a column that used to be displayed is renamed "isLocked".
Looking at the displaylayout columns in code, everything seems fine, but the overwritten column will no longer be displayed.
Here's the displaylayout loaded:
here's what happens after calling myGrid.DisplayLayout.Bands(0).Columns.Add("isLocked"):
I feel like I'm doing everything right and maybe this is just a bug in the grid?
Not sure if this is the issue, buy you should not be using an Encoding when saving or loading the stream data. That will likely damage the integrity of the data. There's another post about this here along with a better method of converting the stream to a string and vice versa.
Thanks Mike. I changed the loading/saving methods to remove the specific encoding, and am still experiencing the same issue.
I use this persistence routine in several grids in my application, but this is the first time I've ever encountered this behavior.
I have the "before" displaylayout XML when the grid is displaying correctly and the "after" XML after I add an unbound column, and it's very different when running it through a diff tool.