Hi, i've been working on this for a while and found some great tips here. But nothing is working .
my problem is:
i have a wingrid bound to bindinglist<T> of a custom DTO. this list is bound to the grid, no problem. i have a saved version of a layout from this grid with all the columns the grid had at the time (i called savelayouttoxml). since then, i have added (only added) new columns to the dto and no matter what i do i always see those columns after i call loadlayoutfromxml. fine, there are new columns the layout doesn't know about it so it shows them. how can i hide them?
i tried hiding all columns before calling loadinglayoutfromxml() but these new columns are always visible. i know they are not in the layout file. even putting the columns at the end of the grid is better than seeing them there. they are right in the front of the grid everytime i add new columns.
i'm currently using layoutcategories.SortedColumns.
what can i do? i've been bald for 20 years and i think i'm going to start pulling my arm hair out.
thanks in advance
If the column does not exist in the layout, then the grid will simply reset that column. There's no way for the grid to know you want the new column to be hidden.
This is easy enough to get around, though. You can load the layout into an UltraGridLayout variable. Then copy it into the grid. Then... loop through the bands and columns and look for columns that do exist in the grid's layout but do not exist in the loaded layout and hide them.
UltraGridLayout layout = new UltraGridLayout(); layout.LoadFromXml(filename); this.ultraGrid1.DisplayLayout.CopyFrom(layout); foreach (UltraGridBand band in this.ultraGrid1.DisplayLayout.Bands) { UltraGridBand loadedBand = layout.Bands[band.Index]; foreach (UltraGridColumn column in band.Columns) { if (false == loadedBand.Columns.Exists(column.Key)) column.Hidden = true; } }
am i expecting the layout to do more than i want? because i know it saves hidden columns.