Xceed Docking Windows for WinForms v2.3 Documentation
Welcome to Xceed Docking Windows for WinForms v2.3 / Task-Based Help / How to save and load a layout

In This Topic
    How to save and load a layout
    In This Topic

    The size, location, visibility, and state of a tool window can be saved and loaded using the DockLayoutManager's SaveLayout and LoadLayout methods. If a tool window specified in the layout does not exist in the ToolWindows collection before the layout is loaded, an exception will be thrown. Normally, a layout would be saved when the application is being closed and loaded after the tool windows have been added to the dock-layout manager's ToolWindows collection. 

    As a "best practice", it is suggested that an application have a default layout which can be embedded into the resources of the application. If the end-user does not have a layout, the default layout can be loaded and applied to the ToolWindows.

    The following code demonstrates how to load a default layout location in the resources of the application. This example assumes that a dock-layout manager has been added to a form and is named dockLayoutManager.

    VB.NET Copy Code

    Dim stream As stream = Me.GetType()..GetManifestResourceStream( "DefaultLayout.xml" )

    Me.dockLayoutManager.LoadLayout( stream )

    stream.Close()

    C# Copy Code

    using( Stream stream = this.GetType()..GetManifestResourceStream( this.GetType(), 
                  "DefaultLayout.xml" ) )
    {
      this.dockLayoutManager.LoadLayout( stream );
    }

     

    The next code snippet demonstrates how to save the current size, location, visibility, and state to a layout located on disk. This example also assumes that a dock-layout manager has been added to a form and is named dockLayoutManager.

    VB.NET Copy Code
    Me.dockLayoutManager.SaveLayout( Me.LayoutFileName )
    C# Copy Code
    this.dockLayoutManager.SaveLayout( this.LayoutFileName );