BaseView.SaveLayoutToJson(Stream, OptionsLayoutBase) Method
Saves the View’s layout settings specified by the options parameter to a file in JSON format.
Namespace: DevExpress.XtraGrid.Views.Base
Assembly: DevExpress.XtraGrid.v26.1.dll
Declaration
Parameters
| Name | Type | Description |
|---|---|---|
| utf8jsonStream | Stream | The layout in UTF-8 encoded JSON format. |
| options | OptionsLayoutBase | Options that define which layout settings to save. null (Nothing in Visual Basic) or OptionsLayoutBase.FullLayout to save all layout settings. |
Remarks
The SaveLayoutToJson(Stream utf8jsonStream) overload method saves layout settings specified by the View’s OptionsLayout property.
string filePath = "gridlayout.json";
void Form1_Load(object sender, EventArgs e) {
if (File.Exists(filePath)) {
using (var jsonStream = File.OpenRead(filePath))
gridView1.RestoreLayoutFromJson(jsonStream);
}
}
void Form1_FormClosing(object sender, FormClosingEventArgs e) {
using (var jsonStream = File.OpenWrite(filePath))
gridView1.SaveLayoutToJson(jsonStream);
}
Use the RestoreLayoutFromJson method to load the layout from a file in JSON format.
Tip
Use the Persistence Behavior or Workspace Manager component to save and restore layouts for all DevExpress UI controls simultaneously.
Important
The Document Manager component identifies child documents by names of controls they host. Ensure control names are unique to prevent errors when saving or restoring layouts.