Hopefully this post may help others and act as a possible feature request.
What I am trying to do save a layout to the database (works fine) but not without filters. However to do this I clear the filters before saving, my problem then lies in restoring the filters after the save.
It would be handy if I did not need to clear them and just choose what to exclude rather than include the one thing I do want when saving with SaveAsXML.
To solve this I first tried making a copy of the old filter settings with the following line:
oldfilters = ugrScenario.DisplayLayout.Bands(0).ColumnFilters
To restore it after clearing and saving it using:
However nothing appears to happen. In the end I got around it by using another SaveAsXML the filter layouts option only to a file, clear the filters and load that file back in again. Seems like a sledge hammer to crack a nut but it does work as a workaround:
'Save the filters to a temporary file.
ugrScenario.DisplayLayout.SaveAsXml(gDBfolderpath & "\Temp.xml", PropertyCategories.ColumnFilters)
'Clear the filters.
'Save the full layout to a file, or file stream in this case (ms).
'Restore the filters from the file and delete the file.
ugrScenario.DisplayLayout.LoadFromXml(gDBfolderpath & "\Temp.xml", PropertyCategories.ColumnFilters)
File.Delete(gDBfolderpath & "\Temp.xml")
I guess I should press preview first! What happened to all the spacing!? :(
You could do what you want with a line of code like the following:
ultraGrid1.DisplayLayout.SaveAsXml("layout.xml", PropertyCategories.AppearanceCollection | PropertyCategories.Bands | PropertyCategories.ColScrollRegions | PropertyCategories.General | PropertyCategories.Groups | PropertyCategories.RowScrollRegions | PropertyCategories.SortedColumns | PropertyCategories.Summaries | PropertyCategories.UnboundColumns | PropertyCategories.ValueLists);
You'll notice that I've included every member of the enumeration except ColumnFilters.
You could also do the same thing like so:
ultraGrid1.DisplayLayout.SaveAsXml( "layout.xml", PropertyCategories.All & ~PropertyCategories.ColumnFilters);
Interesting, though I don't know of any equivilant in vb.net of those operators you have used. Not sure how this works either as the procedure only accepts one none array parameter after the file name. None of the overloads accept an array as a parameter so I am not sure what or indeed how you are doing it.
Am I missing something, is this a C++ only quirk?
The operators are C#-specific, but the logic isn't. The '|' operator in C# is equivalent to the "Or" operator in VB. The '~' operator in C# is equivalent to the 'Not' operator in VB.