BaseView.SaveLayoutToJson(Stream) Method
Saves the View’s layout settings specified by the View’s OptionsLayout property 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. |
Remarks
Use the RestoreLayoutFromJson method to load the layout from a file in JSON format.
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);
}
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.
See Also