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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I persist dockstate in a DataBase?

 

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

Article ID: Published Date: Last Revised Date: Platform: Control:
1395 04/30/2011 07/10/2014 WinForms DockingManager
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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