Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
Choosing what to exclude rather than include when using SaveAsXML


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).

ugrScenario.DisplayLayout.SaveAsXml(ms, Infragistics.Win.UltraWinGrid.PropertyCategories.All)


'Restore the filters from the file and delete the file.

ugrScenario.DisplayLayout.LoadFromXml(gDBfolderpath & "\Temp.xml", PropertyCategories.ColumnFilters)

File.Delete(gDBfolderpath & "\Temp.xml")