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. Image for the cookie policy date

Copying a Grid??

Can we make "Deep Copy" (not a shallow/Clone copy) of a GridControl''s object??

5 Replies

AD Administrator Syncfusion Team July 9, 2004 02:23 AM

You can make a copy of teh GridModel which holds the ''data'' for the GridControl, and use it to generate a deep copy through serilization. System.IO.MemoryStream s = new System.IO.MemoryStream(); grid.SaveBinary(s); GridControl grid1 = new GridControl(GridModel.LoadBinary(s)); s.Close();


MA Maqsood Ahmed July 9, 2004 02:32 AM

I got this Exception.... ************* System.Runtime.Serialization.SerializationException: End of Stream encountered before parsing was completed. at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run() at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, IMethodCallMessage methodCallMessage) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, IMethodCallMessage methodCallMessage) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream) at Syncfusion.Windows.Forms.Grid.GridModel.LoadBinary(Stream s) ***************


AD Administrator Syncfusion Team July 9, 2004 02:45 AM

Between saving it an dreading it back, you has the reset the cursor in the IOStream. s.Seek(0, System.IO.SeekOrigin.Begin);


MA Maqsood Ahmed July 9, 2004 03:39 AM

Well it copies one grid to the other, but i changes many properties of the grid I copy. Such as Height, width, even Parent too. any sugestions?


AD Administrator Syncfusion Team July 9, 2004 04:02 AM

This code copies the GridModel which contains all the GridStyleInfo information, colwidths, etc which are properties of the grid data. It does not copy any Control properties like Control.Size or Control.Location or ????. If you need to persist things like grid.Size or grid.Location, then you would have to write them out to the memmory stream, and then read them back in separately, or you could hook into the ISerializable interface with a derived grid that serializes the properties you want to persist in your copy.

Loader.
Live Chat Icon For mobile
Up arrow icon