KB Article A1652
Visible to All Users

How to manage the loading of old layouts after releasing a new version of my application

Description:
I allow my end-users to customize the grids' layouts and store/restore them via the SaveLayoutToXml and RestoreLayoutFromXml methods.
The problem is:
a) A client installed version 1.0 of my software.
b) He saved layouts with this version.
c) I developed version 1.1 and changed the widths, sorting, and other settings of the columns in my grid.
d) The client installed the new version of my software. When he restores a layout, the new settings are lost.
How can I restore the "old" layouts without losing the new settings?

Answer:
Applies to:
XtraGrid, XtraBars, XtraPivotGrid, XtraTreeList, XtraVerticalGrid, XtraNavBar, XtraLayoutControl
In most cases, the grid can mix design-time design with end-user customizations, because only those layout settings which can be changed by end-users are saved: column visibility, grouping, filters, etc. For example, when you add a new column to your grid and release a new version of your application, the grid will display the new column after loading an old layout.
However, if you significantly change the grid, e.g. reorder columns, group and sort them, a saved layout of the previous version of your application will override your design. In such cases, we advise that you change the GridView.OptionsLayout.LayoutVersion property to indicate a new generation of the grid layout. Then you can prevent the old layout from being loaded by handling the BeforeLoadLayout event and setting the e.Allow parameter to False depending on the e.PreviousVersion and OptionsLayout.LayoutVersion values. You can also let the grid load an old layout, but then apply the necessary changes by handling the LayoutUpgrade event. The additional information on the mentioned properties and members can be found in the XtraGrid documentation.
Actually, the task of upgrading layouts is more common to the XtraBars rather than the grid. When you add a new button and want it to be visible on a toolbar after loading an old customization, you must use the LayoutVersion property and handle the LayoutUpgrade event to add the button to the toolbar programmatically:

C#
<aBar>.ItemLinks.Add(<aNewBarItem>);

See Also:
Saving and Restoring the Layout of Views in the XtraGrid help
Why are columns/bands which are created at runtime not stored/restored by the SaveLayoutTo~/RestoreLayoutFrom methods
BarManager.LayoutVersion Property
Why are the Items created in code not restored when loading settings?

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.