TreeList.RestoreLayoutFromJson(Stream, OptionsLayoutBase) Method
SECURITY-RELATED CONSIDERATIONS
Deserializing layout settings from untrusted resources may create security issues. Review the following help topic for additional information: Safe Deserialization.
Loads the TreeList’s layout settings specified by the options parameter from a file in JSON format.
Namespace: DevExpress.XtraTreeList
Assembly: DevExpress.XtraTreeList.v25.2.dll
NuGet Packages: DevExpress.Win.Navigation, DevExpress.Win.TreeList
Declaration
public virtual void RestoreLayoutFromJson(
Stream utf8jsonStream,
OptionsLayoutBase options
)
Parameters
| Name | Type | Description |
|---|---|---|
| utf8jsonStream | Stream | The layout in UTF-8 encoded JSON format. |
| options | OptionsLayoutBase | Options that define which layout settings to load. null (Nothing in Visual Basic) or OptionsLayoutBase.FullLayout to load all layout settings. |
Remarks
Use the SaveLayoutToJson method to save the layout to a file in JSON format.
string filePath = "treelist-layout.json";
void Form1_Load(object sender, EventArgs e) {
if (File.Exists(filePath)) {
using (var jsonStream = File.OpenRead(filePath))
treeList1.RestoreLayoutFromJson(jsonStream);
}
}
void Form1_FormClosing(object sender, FormClosingEventArgs e) {
using (var jsonStream = File.OpenWrite(filePath))
treeList1.SaveLayoutToJson(jsonStream);
}
Tip
Use the Persistence Behavior or Workspace Manager component to save and restore layouts for all DevExpress UI controls simultaneously.