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
am i expecting the layout to do more than i want? because i know it saves hidden columns.
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; } }
wTh. that worked like a charm mike. thanks.
Hi Al,
PropertyChanged is a sort've catch-all for any property changing anywhere in the grid. Although it's actually not that simple, because there are certain properties in the grid that are ignored for performance reasons.
Using that event will work to a certain extent, but it may be overkill. PropertyChanged may fire for things that don't affect the layout (although I can't think of an example, off hand).
The alternative would be to use a multitude of events and try to catch all of the possible ways in which the user might alter the layout, so PropertyChanged is certainly the easiest event to use.
looks like PropertyChanged (Infragistics.Win.PropertyChangedEventArgs ) does what i'm looking for. so far it works with testing.
sorry, I mean comparing a copy of the layout before to a copy of the layout after.
hey Mike,
is it possible, using the same idea of copying layouts, to determine whether or not something in the layout has changed. So when the user closes the form I can do that check and ask them if they want to save the changes or not.
Thanks again