BaseView.RestoreLayoutFromXml(String) Method
SECURITY NOTE
Deserializing layout settings from untrusted resources may create security issues. Review the following help topic for additional information: Safe Deserialization.
Restores a View’s layout from a specific XML file.
Namespace: DevExpress.XtraGrid.Views.Base
Assembly: DevExpress.XtraGrid.v24.2.dll
NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation
#Declaration
#Parameters
Name | Type | Description |
---|---|---|
xml |
String | A string value specifying the path to the XML file from which View settings are read. If the specified file doesn’t exist, System. |
#Remarks
Use the RestoreLayoutFromXML method to load the View’s layout previously saved to an XML file with the help of the BaseView.SaveLayoutToXml method.
The ColumnView.OptionsLayout property controls which settings should be restored from the file.
Note
When restoring a layout during a form load (for instance, in your Form.
#Example
This example shows how to save and restore the layout of the GridControl.MainView between application runs. The form’s Load event is handled to restore the layout previously saved to an XML file. The form’s Closing event is handled to save the current layout to the specified file.
Note that the GridControl.ForceInitialize method is called before the layout is restored in the Form.Load event. This method needs to be called before a grid’s settings are changed in the Form.Load event. It finishes the control’s initialization and thus ensures that all the changes that will be made do not conflict with the options that have been customized at design time.
using DevExpress.XtraGrid;
// ...
string fileName = "c:\\XtraGrid_SaveLayoutToXML.xml";
private void Form1_Load(object sender, System.EventArgs e) {
gridControl1.ForceInitialize();
// Restore the previously saved layout
gridControl1.MainView.RestoreLayoutFromXml(fileName);
}
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
// Save the layout to an XML file
gridControl1.MainView.SaveLayoutToXml(fileName);
}
#Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the RestoreLayoutFromXml(String) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.