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

serializing a GridModel used as part of a datastructure

Thread ID:

Created:

Updated:

Platform:

Replies:

104474 Jul 22,2012 10:29 AM UTC Aug 2,2012 12:35 PM UTC Windows Forms 3
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On July 22, 2012 10:29 AM UTC

In the attached example I use a GridModel as a scratchpad structure. Unless I have copied values
into this GridModel, I am unable to save and load the data structure successfully. Is there a way to
do so? In the real app, the GridModel may be empty because there are a lot of preliminary steps
which the user must complete before reaching the step where the scratchpad is used. This could
take days or weeks. Hence, saving at intermediate stages becomes a necessity.
 
v/r
Jan
 


Example_8bc3178a.rar

Kalaiarasan B [Syncfusion]
Replied On July 30, 2012 07:10 AM UTC

Hi Jan,

 Thank you for your interest in Syncfusion products.

 You can serialize the GridModel directly to binary format using the SaveBinary() and so you can use the following way to achieve the desired behavior instead of serializing using BinaryFormatter and Stream.

 // Serialize

if (dr == System.Windows.Forms.DialogResult.OK)

            {

                dataStructure.Textbox1Text = textBox1.Text;

                dataStructure.Textbox2Text = textBox2.Text;

                this.gridControl1.Model.SaveBinary(saveFileDlg.FileName);

            }

 

//Deserialize

if (dr == System.Windows.Forms.DialogResult.OK)

            {

                this.gridControl1.Model = GridModel.LoadBinary(openFileDlg.FileName);

                this.gridControl1.Refresh();

                textBox1.Text = dataStructure.Textbox1Text;

                textBox2.Text = dataStructure.Textbox2Text;

            }

 Sample for your reference

 http://www.syncfusion.com/downloads/Support/DirectTrac/96689/Example-349884176.zip

 Please let us know if you have any concerns

 Regards,

Kalai


Administrator [Syncfusion]
Replied On July 30, 2012 10:09 PM UTC

Your approach saves the grid model but does not save the data structure. I wish to save a data structure, one element of which is a grid model, as a single file. Using your approach would require saving the data structure as 2 files (1 file for the 'non-grid' data elements and another for the grid model).

Kalaiarasan B [Syncfusion]
Replied On August 2, 2012 12:35 PM UTC

Hi Jan,

Hi Jan,

It is not possible to save the GridModel like in your sample, only LoadBinary, LoadSoap can serialize the GridModel without any null refernce exceptions. 

So it would be better if you serialize the Grid and the datastructure in the previous approach.

Regards,
Kalai

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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

;