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

Deserialization loses scroll bars

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

1 Reply

AD Administrator Syncfusion Team August 16, 2006 04:39 AM UTC

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

Loader.
Live Chat Icon For mobile
Up arrow icon