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

Persisting column sizes

I am using a GridGroupingControl with 5 nested tables. I want to remember column sizes whenever they are changed and set them whenever the program is started.

Is using:

this.gridGroupingControl1.GetTableControl(TableName).Model.ColWidths[ColumnName] = saved width;

The best way to restore the widths?

Is using:

OnTableControlResizingColumns event of the GridGroupingControl

the best event to trap? Will this catch resizes across all 5 tables?

Would I use the MouseUp reason?

Thanks!

WJL




5 Replies

AD Administrator Syncfusion Team August 16, 2006 05:30 PM UTC

I think you can just set properties in Form.Load (or wherever you initialize your groupinggrid). The properties you want to set would be TableDescriptor.Columns[colName].Width for all the tables and all the columns. So, instead of using the ColWidths collection (inherited from GridControlBase), use the Width properties on the GridColumnDescriptors for all the tables.

Another option you may want to consider is to use the built-in xml schema serialization support (it saves more than colwidths, but does save the widths). Take a look at this sample. \Syncfusion\Essential Studio\4.2.0.37\Windows\Grid.Grouping.Windows\Samples\CategoryView


BL Bill Langlais August 17, 2006 03:32 AM UTC

I tried wrining the engine settings using the following:




void
Form1::SaveSkiResultsGrid(String *FileName)
{
XmlTextWriter *xw = new XmlTextWriter(S"SkiTrackGrid.XML", System::Text::Encoding::UTF8);
P_GridSkiResults->WriteXmlSchema(xw);
xw->Close();
}


I tried this in two places, one in a event handler for the GridSkiResultsSelectedRecordsChanged
(put here for testing convienience)

the other in the _tWinMain as follows:


Application::Run(MainWindow);
MainWindow->SaveSkiResultsGrid(S"BeforeExit.xml");


Included are the two resulting xml files. The onw in _tWinMain seems to have nothing of value in it and the other does not have any column widths even though I resized two colums

I wanted to use the _tWinMain since it would contain the last changes but that seems to not store anything.

WJL


XmlFiles.zip


AD Administrator Syncfusion Team August 17, 2006 07:55 AM UTC

Try handling the Form.Closing event for the form that holds P_GridSkiResults grid and write out the XML there to see if that will save the column widths. It does for me in a simple sample using version 4.2.0.60. If that does not work, there must be something else going on. Place a stop where you try to write out the XML and look at the values for the TableDescriptor.Column[colIndex].Width to see if they are as expected.

Are you doing anything special with your GridGroupingControl, like deriving it and overriding various methods or using a custom grouping engine for some reason?


BL Bill Langlais August 18, 2006 02:40 AM UTC

The Form Closing woked better then using WinMain. But the problem is that I have 5 nested tables and on the the changes to the top level table are written out. Is there a way to write out all five tables?


AD Administrator Syncfusion Team August 18, 2006 02:19 PM UTC

Here is a sample where column sizes in nested tables are being persisted for me using 4.2.0.60.

http://www.syncfusion.com/Support/user/uploads/GGC_Nestedtables_964c9c29.zip

Are you doing something different?

Loader.
Live Chat Icon For mobile
Up arrow icon