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.

Deserialization loses scroll bars

Thread ID:

Created:

Updated:

Platform:

Replies:

47882 Aug 15,2006 05:31 PM Aug 16,2006 12:39 AM Windows Forms 1
loading
Tags: GridControl
John Dumais
Asked On August 15, 2006 05:31 PM

Hello,

I''m trying to figure out a problem I''ve run into using a GridControl. I use the SetRowHidden method to expand/collapse some the rows in the grid. When the grid expands and contracts, it creates or removes a vertical scroll bar as necessary. That''s good. Trouble is, when I serialize the grid, then deserialize it, the newly-deserialized grid instance loses the vertical scroll bar. To get the scroll bar to update, I need to collapse all the grid rows under one main row, then expaned things out again. I was wondering how to serialize/deserialize the grid and keep the scroll bars updated correctly? Here''s how I serialize/deserialize...

private void saveButton_Click(object sender, System.EventArgs e)
{
Stream stream;
SaveFileDialog saveFileDialog1 = new SaveFileDialog();

saveFileDialog1.Filter = string.Format("{0} files (*.xml)|*.xml", EnvironmentSetup.GetSTWAppName());
saveFileDialog1.FilterIndex = 0 ;
saveFileDialog1.RestoreDirectory = true ;
saveFileDialog1.InitialDirectory = controller.ProjectDirectory;

if(saveFileDialog1.ShowDialog() == DialogResult.OK)
{
if((stream = saveFileDialog1.OpenFile()) != null)
{
this.Cursor = Cursors.WaitCursor;
this.saveButton.Enabled = false;

try
{
StreamWriter sw = new StreamWriter(stream);
IFormatter formatter = new SoapFormatter();
formatter.Serialize(stream, gridControl1.Model);
sw.Close();
stream.Close();
}
finally
{
this.saveButton.Enabled = true;
this.Cursor = Cursors.Default;
}
}
}
}


IFormatter formatter = new SoapFormatter();
gridControl1.Model = (GridModel)formatter.Deserialize(stream);
this.Invalidate();


Thanks


temp3.zip

Administrator [Syncfusion]
Replied On August 16, 2006 12:39 AM

Hi John,

After the deserialize the grid, you can call the ResetVolatileData and Refresh method to refresh the grid.

this.grid.ResetVolatileData();
this.grid.Refresh();

Suggestion :

There is a built-in method for serializing/de-serializing the Grid. You can use the SaveSoap method to serialize the GridModel and use the LoadSoap method to de-serialize the GridModel. Please find the code snippet below.

this.grid.Model.SaveSoap("FileName");

//Static method in GridModel Class.
GridModel.LoadSoap("FileName");

Best Regards,
Haneef

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.

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.

;