Skip to main content
All docs
V25.2
  • BaseView.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 View’s layout settings specified by the options parameter from a file in JSON format.

    Namespace: DevExpress.XtraGrid.Views.Base

    Assembly: DevExpress.XtraGrid.v25.2.dll

    NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation

    Declaration

    public 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 = "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.

    See Also