WorkspaceManager.ApplyWorkspace(String) Method

Locates a workspace with the target name within the WorkspaceManager.Workspaces collection and applies it to the application.

Namespace: DevExpress.Utils

Assembly: DevExpress.Utils.v20.1.dll


public void ApplyWorkspace(
    string name
Public Sub ApplyWorkspace(
    name As String


Name Type Description
name String

A String value that is the workspace name within the WorkspaceManager.Workspaces collection.


Before the ApplyWorkspace method is executed, the WorkspaceManager.BeforeApplyWorkspace event is raised.

The ApplyWorkspace method applies a workspace that is already loaded into the WorkspaceManager.Workspaces collection. To add a workspace to this collection, use the WorkspaceManager.LoadWorkspace method.


Before applying a workspace during a form load (for instance, in your Form.Load event handler), you may need to call the ForceInitialize methods of the controls contained in the workspace. These methods are: BarManager.ForceInitialize, DataLayoutControl.ForceInitialize, DockManager.ForceInitialize, DocumentManager.ForceInitialize, GridControl.ForceInitialize, PivotGridControl.ForceInitialize, RibbonControl.ForceInitialize and TreeList.ForceInitialize.


The following code shows how to use the WorkspaceManager component to save the form's bounds and state, and the layout of DevExpress controls when a form is closed, and load this layout when the form starts.

You may need to call the controls' ForceInitialize methods (e.g., GridControl.ForceInitialize) before applying layouts to the controls in a Form.Load event handler.

 string file = "layout.xml";
 string workspaceName1 = "MyLayout";

 private void Form1_Load(object sender, EventArgs e) {
     //Use the WorkspaceManager to handle the layout of DevExpress controls that reside within the current form.
     workspaceManager1.TargetControl = this;

     // Save & restore the form's size, position and state along with DevExpress controls' layouts.
     workspaceManager1.SaveTargetControlSettings = true;

     // Disable layout load animation effects 
     workspaceManager1.AllowTransitionAnimation = DevExpress.Utils.DefaultBoolean.False;

    // Disable (de)serialization for the following controls (if required):
    //WorkspaceManager.SetSerializationEnabled(gaugeControl1, false);
    //WorkspaceManager.SetSerializationEnabled(accordionControl1, false);

    // When restoring layouts of controls in a Form.Load event handler,
    // you may need to call the controls' ForceInitialize methods to finish their initialization before restoring their layouts.

     //Load DevExpress controls' layouts from a file
     if (workspaceManager1.LoadWorkspace(workspaceName1, file, true))

 private void Form1_FormClosed(object sender, FormClosedEventArgs e) {
     //Save DevExpress controls' layouts to a file
     workspaceManager1.CaptureWorkspace(workspaceName1, true);
     workspaceManager1.SaveWorkspace(workspaceName1, file, true);
See Also