How to configure State Persistence for Docking child controls added in runtime?
In DockingManager control, State Persistence can be configured for Docking Child controls that created in run time and it will be applied for the Docking child controls only if it is currently active.
This below article helps to understand this process.
Step 1:
Here Create and load Docking Child control in DockingManager by clicking on Add button.

Step 2:
Now saving the state of currently active Docking child controls by using SaveDockState function.

Step 3:
Close and restart the application. Most end users misunderstand in this scenario and presume clicking Load Button will load Docking Child controls, that were added in application. But it’s not how DockingManager control State Persistence will work.

In DockingManager, State Persistence will be applied in iteration process. When LoadDockState function is called, then each of Docking Child will be applied with saved state in Iteration process. So, it is needed to load Dynamically created child with same DockLabel information, before applying saved state. Please refer to below screenshot.

C#
private Panel m_panelDisplayData;
private Panel panel;
private DockingManager m_dockingManagerForDisplay;
public Form1()
{
InitializeComponent();
//Initialize the dock panel
m_panelDisplayData = new Panel();
panel = new Panel();
panel.Width = 300;
panel.Name = "panel";
m_panelDisplayData.Width = 250;
m_panelDisplayData.Name = "neww";
//Initialize the docking manager and the tabbed MDI manager
try
{
m_dockingManagerForDisplay = new DockingManager();
}
catch (Exception ex)
{
throw ex;
}
//Set properties for the docking manager
m_dockingManagerForDisplay.ActiveCaptionFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World);
m_dockingManagerForDisplay.HostControl = this;
m_dockingManagerForDisplay.CaptionButtons.Add(new Syncfusion.Windows.Forms.Tools.CaptionButton(Syncfusion.Windows.Forms.Tools.CaptionButtonType.Close, "CloseButton"));
m_dockingManagerForDisplay.CaptionButtons.Add(new Syncfusion.Windows.Forms.Tools.CaptionButton(Syncfusion.Windows.Forms.Tools.CaptionButtonType.Pin, "CloseButton"));
m_dockingManagerForDisplay.CaptionButtons.Add(new Syncfusion.Windows.Forms.Tools.CaptionButton(Syncfusion.Windows.Forms.Tools.CaptionButtonType.Restore, "RestoreButton"));
//Enable docking fo the panel
this.m_dockingManagerForDisplay.DockControl(this.m_panelDisplayData, this, DockingStyle.Left, 150);
m_dockingManagerForDisplay.SetEnableDocking(m_panelDisplayData, true);
//Set label to the panels in the form.
m_dockingManagerForDisplay.SetDockLabel(m_panelDisplayData, "Panel1");
this.Text = "Restore Layout";
}
//To add the Panel dynamically
private void button1_Click(object sender, EventArgs e)
{
this.m_dockingManagerForDisplay.DockControl(this.panel, this, DockingStyle.Right, 150);
m_dockingManagerForDisplay.SetEnableDocking(panel, true);
m_dockingManagerForDisplay.SetDockLabel(panel, "Dynamic Panel");
}
// To store the DockingManager current state in XML File
private void button2_Click(object sender, EventArgs e)
{
AppStateSerializer serializer = new AppStateSerializer(SerializeMode.XMLFile, "myfile2");
this.m_dockingManagerForDisplay.SaveDockState(serializer);
serializer.PersistNow();
}
// To load the the saved state
private void button3_Click(object sender, EventArgs e)
{
AppStateSerializer serializer = new AppStateSerializer(SerializeMode.XMLFile, "myfile2");
this.m_dockingManagerForDisplay.LoadDockState(serializer);
}
VB
Dim m_panelDisplayData As Panel
Dim panel As Panel
Dim m_dockingManagerForDisplay As DockingManager
publicForm1
InitializeComponent
'Initialize the dock panel
m_panelDisplayData = New Panel
panel = New Panel
panel.Width = 300
panel.Name = "panel"
m_panelDisplayData.Width = 250
m_panelDisplayData.Name = "neww"
'Initialize the docking manager and the tabbed MDI manager
Try
m_dockingManagerForDisplay = New DockingManager
Catch ex As Exception
Throw ex
End Try
'Set properties for the docking manager
m_dockingManagerForDisplay.ActiveCaptionFont = New System.Drawing.Font("Segoe UI", 12!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World)
m_dockingManagerForDisplay.HostControl = Me
m_dockingManagerForDisplay.CaptionButtons.Add(New Syncfusion.Windows.Forms.Tools.CaptionButton(Syncfusion.Windows.Forms.Tools.CaptionButtonType.Close, "CloseButton"))
m_dockingManagerForDisplay.CaptionButtons.Add(New Syncfusion.Windows.Forms.Tools.CaptionButton(Syncfusion.Windows.Forms.Tools.CaptionButtonType.Pin, "CloseButton"))
m_dockingManagerForDisplay.CaptionButtons.Add(New Syncfusion.Windows.Forms.Tools.CaptionButton(Syncfusion.Windows.Forms.Tools.CaptionButtonType.Restore, "RestoreButton"))
'Enable docking of the panel
Me.m_dockingManagerForDisplay.DockControl(Me.m_panelDisplayData, Me, DockingStyle.Left, 150)
m_dockingManagerForDisplay.SetEnableDocking(m_panelDisplayData, true)
'Set label to the panels in the form.
m_dockingManagerForDisplay.SetDockLabel(m_panelDisplayData, "Panel1")
Me.Text = "Restore Layout"
'To add the Panel dynamically
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Me.m_dockingManagerForDisplay.DockControl(Me.panel, Me, DockingStyle.Right, 150)
m_dockingManagerForDisplay.SetEnableDocking(panel, true)
m_dockingManagerForDisplay.SetDockLabel(panel, "Dynamic Panel")
End Sub
' To store the DockingManager current state in XML File
Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim serializer As AppStateSerializer = New AppStateSerializer(SerializeMode.XMLFile, "myfile2")
Me.m_dockingManagerForDisplay.SaveDockState(serializer)
serializer.PersistNow
End Sub
' To load the saved state
Private Sub button3_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim serializer As AppStateSerializer = New AppStateSerializer(SerializeMode.XMLFile, "myfile2")
Me.m_dockingManagerForDisplay.LoadDockState(serializer)
End Sub
Samples: