)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to persist dock state in a database of WinForms Docking Manager?

Platform: WinForms |
Control: DockingManager |
Published Date: April 30, 2011 |
Last Revised Date: December 5, 2019

Serialize dock state

To persist docking information into a data base. It is necessary to serialize the state information into a stream. After that, the stream is written into the database. Please refer to the below code snippet which illustrates this.

C#

private void button1_Click(object sender, EventArgs e)
{
   // Saving dockstate to memory stream
   MemoryStream ms = new MemoryStream();
   AppStateSerializer aser = new AppStateSerializer(SerializeMode.BinaryFmtStream, ms);
   this.dockingManager1.SaveDockState(aser);
   aser.PersistNow();
   //Code to store the memory stream into database.Depends upon the database
   MessageBox.Show("Saved in DB");
}
private void button2_Click(object sender, EventArgs e)
{
   //Code to retrieve data(stream) from database. Depends upon the database
   //Retrive dockState from DB
   String val = "";
   byte[] bytes = System.Text.Encoding.ASCII.GetBytes(val);
   MemoryStream ms = new MemoryStream(bytes);
   ms.Position = 0;
   AppStateSerializer aser = new AppStateSerializer(SerializeMode.BinaryFmtStream, ms);
   this.dockingManager1.LoadDockState(aser);
   MessageBox.Show("Loaded from DB");
}

 

VB

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
   'Saving dockstate to memory stream
   Dim ms As MemoryStream = New MemoryStream()
   Dim aser As AppStateSerializer = New AppStateSerializer(SerializeMode.BinaryFmtStream, ms)
   Me.DockingManager1.SaveDockState(aser)
   aser.PersistNow()
   'Code to store the memory stream into database.Depends upon the database
   MessageBox.Show("Saved in DB")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
   'Code to retrieve data(stream) from database.Depends upon the database
   'Retrive dockState from DB
   Dim val As String = ""
   Dim bytes As Byte() = System.Text.Encoding.ASCII.GetBytes(val)
   Dim ms As MemoryStream = New MemoryStream(bytes)
   ms.Position = 0
   Dim aser As AppStateSerializer = New AppStateSerializer(SerializeMode.BinaryFmtStream, ms)
   Me.DockingManager1.LoadDockState(aser)
   MessageBox.Show("Loaded from DB")
End Sub

 

Sample: http://help.syncfusion.com/support/samples/KB/Tools.Windows/TDDBper/DBper.zip

UG document link: https://help.syncfusion.com/windowsforms/dockingmanager/serialization

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon