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