Nevron .NET Vision Documentation
Serializing the Control State

The Serializer can also save/load the control state to a file and stream.

Serializing the Control State to Stream

You can use the SaveControlStateToStream and LoadControlStateToStream methods to load/save the entire chart control state to a stream. This is how it's done:

C#
Copy Code
MemoryStream memoryStream = new MemoryStream();

// save the control state
chartControl.Serializer.SaveControlStateToStream(memoryStream, PersistencyFormat.Binary, null);

// load the controls state
memoryStream.Position = 0;
chartControl.Serializer.LoadControlStateFromStream(memoryStream, PersistencyFormat.Binary, null);
Visual Basic
Copy Code
Dim memoryStream As New MemoryStream

' save the control state
chartControl.Serializer.SaveControlStateToStream(memoryStream, PersistencyFormat.Binary, Nothing)

' load the controls state
memoryStream.Position = 0
chartControl.Serializer.LoadControlStateFromStream(memoryStream, PersistencyFormat.Binary, Nothing)

Note that you have to reset the stream position before loading the state:

C#
Copy Code
// go back to the beginning of the stream
memoryStream.Position = 0;
Visual Basic
Copy Code
' go back to the beginning of the stream
memoryStream.Position = 0
Serializing the Control State to File

Alternatively you can use the SaveControlStateToFile and LoadControlStateFromFile to load/save the control state from a file:

C#
Copy Code
// save the control state
chartControl.Serializer.SaveControlStateToFile("c:\\temp\\chart.bin", PersistencyFormat.Binary, null);

// load the controls state
chartControl.Serializer.LoadControlStateFromFile("c:\\temp\\chart.bin", PersistencyFormat.Binary, null);
Visual Basic
Copy Code
' save the control state
chartControl.Serializer.SaveControlStateToFile("c:\\temp\\chart.bin", PersistencyFormat.Binary, Nothing)

' load the controls state
chartControl.Serializer.LoadControlStateFromFile("c:\\temp\\chart.bin", PersistencyFormat.Binary, Nothing)
Related Examples
Windows Forms: Serialization\Control State
See Also

 

 


©2017. Nevron Software LLC.

Send Feedback