GridStyleInfo serialisation

I want to save custom visual properties of my grid which are stored in a series of GridStyleInfo objects (styles for the currently selected row, selected cell and alternating "blocks" of rows for example). Is there an (easy) way to save all those properties (background color, font, text color, etc.) in XML. Maybe i'm doing it wrong. I'm using GridStyleInfo object because it seemed like a good idea at the time ;) thx Olivier

1 Reply

AD Administrator Syncfusion Team June 25, 2003 12:16 PM UTC

Did you derive from the GridStyleInfoCustomProperties class? If yes, then you can take advantage of built-in Xml serialization features for style objects in the 1.6 version. If you have a GridData object, you can serialize this one as follows: Stream s = File.OpenWrite("C:/ttt.xml"); XmlWriter xw = new XmlTextWriter(s, System.Text.Encoding.Default); XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(model.Data.GetType()); xs.Serialize(xw, model.Data); s.Close(); To load a data object: Stream s = File.OpenRead("C:/ttt.xml"); XmlReader xw = new XmlTextReader(s); XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(model.Data.GetType()); model.Data = (GridData) xs.Deserialize(xw); s.Close(); You can also serialize an individual style object of course that same way (just replace the type when creating the XmlSerializer). Stefan

Loader.
Up arrow icon