Assembly: Dapfor.Net (in Dapfor.Net.dll) Version: 2.10.3.24917 (2.10.3.24917)
Syntax
C# |
---|
[SerializableAttribute] public class HeaderSerializationState : ISerializable, IXmlSerializable |
Visual Basic |
---|
<SerializableAttribute> Public Class HeaderSerializationState Implements ISerializable, IXmlSerializable |
Visual C++ |
---|
[SerializableAttribute] public ref class HeaderSerializationState : ISerializable, IXmlSerializable |
F# |
---|
[<SerializableAttribute>] type HeaderSerializationState = class interface ISerializable interface IXmlSerializable end |
Remarks
Data serialization is a process of saving user preferences for a grid, such as colors, columns location, grouping, sorting and other data into an archive for further deserialization. For example, this feature may be useful when you restart your application. In general, this procedure is very complex and requires familiarity with XML or binary archives. Besides that, a programmer sometimes fails to save state of the whole application, which results in loss of data and user preferences
We provide you with a very convenient and efficient way to save and restore the grid's state. The .Net Grid supports serialization in XML as well as in binary formats via the SerializationState property. The object returned by this property implements IXmlSerializable and ISerializable interfaces which allow it to be serialized into XML or binary files. During deserialization this object is restored from these files and is passed to the grid via the Grid.SerializationState property.
Example of XML serialization:
Copy | |
---|---|
//The method serializes the grid's state into the XML file void XmlSerialization(Grid grid, string fileName) { using (FileStream fs = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write)) { XmlSerializer serializer = new XmlSerializer(typeof(Grid.GridSerializationState)); serializer.Serialize(fs, grid.SerializationState); } } //The method deserializes the grid's state from the XML file void XmlDeserialization(Grid grid, string fileName) { using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { XmlSerializer serializer = new XmlSerializer(typeof(Grid.GridSerializationState)); grid.SerializationState = (Grid.GridSerializationState)serializer.Deserialize(fs); } } |
Example of binary serialization:
Copy | |
---|---|
//The method serializes the grid's state into the XML file void BinarySerialization(Grid grid, string fileName) { using (FileStream fs = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write)) { BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(fs, grid.SerializationState); } } //The method deserializes the grid's state from the XML file void BinaryDeserialization(Grid grid, string fileName) { using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { BinaryFormatter formatter = new BinaryFormatter(); grid.SerializationState = (Grid.GridSerializationState)formatter.Deserialize(fs); } } |
A very nice feature of the Dapfor.Net Grid is that a programmer may transfer state of one grid into another:
Copy | |
---|---|
grid1.SerializationState = grid2.SerializationState; |