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

Persisting grid style info between runs

Thread ID:

Created:

Updated:

Platform:

Replies:

6824 Aug 29,2003 12:20 PM UTC Sep 5,2009 06:38 AM UTC Windows Forms 9
loading
Tags: GridControl
Doug Lind
Asked On August 29, 2003 12:20 PM UTC

Hello all, We are going to be using Essential Grid for a number of displays in a windows forms application. Part of the requirement is that the user be able to configure and save individual grid layouts (hidden columns, column order, column width, and column name). I was hoping that there was a method to save the style info and reload it, between application runs. After looking through the docs, it appears that I will need to serialize the styleinfo class, save it to a file and reload. Am I on the right track here? cane anyone suggest a better method? Thanks, Doug Panther Systems

Administrator [Syncfusion]
Replied On August 29, 2003 12:56 PM UTC

If this is a GridControl, then you can use GridModel.LoadBinary and GridModel.SaveBinary (or LoadSoap & SaveSoap) to serialize your grids. If these are GridDataBoundGrids, then we currently don't support direct serialization og this grid. We will at some point. Right now, you would have to do things yourself. Here is a forum tread that has a sample that serializes out column order and size. http://www.syncfusion.com/forums/message.asp?MessageID=3918

Doug Lind
Replied On August 29, 2003 01:23 PM UTC

Thanks Clay, This looks like a goood approach for me. Doug > If this is a GridControl, then you can use GridModel.LoadBinary and GridModel.SaveBinary (or LoadSoap & SaveSoap) to serialize your grids. > > If these are GridDataBoundGrids, then we currently don't support direct serialization og this grid. We will at some point. Right now, you would have to do things yourself. Here is a forum tread that has a sample that serializes out column order and size. http://www.syncfusion.com/forums/message.asp?MessageID=3918

Santosh U
Replied On July 17, 2009 02:57 PM UTC

Hi,

The above given links seems to be not working. Can you please update me with the new link. This will be very useful feature.

Thanks

Rajadurai C [Syncfusion]
Replied On July 17, 2009 03:04 PM UTC

Hi Santosh,

Thanks for your interest in Syncfusion Products.

Please refer to the forum thread through the following link.
http://www.syncfusion.com/support/forums/grid-windows/3918

Regards,
Rajadurai

Santosh U
Replied On July 24, 2009 03:29 PM UTC

Hi Rajdurai,

I am sorry, I had tried to download the project link which was given but the zip file seems to be not available now. I get 404 error.

Would it be possible to provide some project (C#).

Thanks,
Satosh U.

Peter Trevor
Replied On July 24, 2009 05:40 PM UTC

Hi. I'm not a Syncfusion expert but if it's a GridGroupingControl that you want to persist the style of I use the following code:

private void SetGridProperties(GridGroupingControl thisGrid, string thisID)
{
try
{
XmlReader xr1 = new XmlTextReader(thisID + "Schema.xml");
XmlReader xr2 = new XmlTextReader(thisID + "LooknFeel.xml");
thisGrid.ApplyXmlSchema(xr1);
thisGrid.ApplyXmlLookAndFeel(xr2);
xr1.Close();
xr2.Close();
}
catch
{
thisGrid.TableModel.ColWidths.ResizeToFit(GridRangeInfo.Row(0), GridResizeToFitOptions.None);
for (int i = 1; i <= thisGrid.TableModel.RowCount; i++)
thisGrid.TableModel.ColWidths.ResizeToFit(GridRangeInfo.Row(i), GridResizeToFitOptions.NoShrinkSize);
}
}

private void SaveGridProperties(GridGroupingControl thisGrid, string thisID)
{
try
{
XmlTextWriter xw1 = new XmlTextWriter(thisID + "GridSchema.xml", Encoding.UTF8);
XmlTextWriter xw2 = new XmlTextWriter(thisID + "GridLooknFeel.xml", Encoding.UTF8);
xw1.Formatting = Formatting.Indented;
xw2.Formatting = Formatting.Indented;
thisGrid.WriteXmlSchema(xw1);
thisGrid.WriteXmlLookAndFeel(xw2);
xw1.Close();
xw2.Close();
}
catch
{
}
}


Rajadurai C [Syncfusion]
Replied On July 31, 2009 02:43 PM UTC

Hi Santhosh,

I apologize for the delay in responding.

Please refer to the following link that holds the sample mentioned in Forum:#3918.
http://files.syncfusion.com/support/samples/Grid.Windows/7.3.0.20/2862-1Modified.zip

Regards,
Rajadurai

Santosh U
Replied On August 13, 2009 03:14 PM UTC

Hi Rajadurai,

I have tried this and its working fine. I changed to use for GGC but it give me some weired output. I have copied the code which i have changed below.

try
{
//serialize out the row heights & columnwidths
IFormatter formatter = new BinaryFormatter();
Stream stream = new FileStream("MySizes.bin", FileMode.Create, FileAccess.Write, FileShare.None);

//handle the mappingnames
//GridBoundColumnsCollection col = (GridBoundColumnsCollection)this.gridDataBoundGrid1.GridBoundColumns;

GridColumnDescriptorCollection col = (GridColumnDescriptorCollection)gridGroupingControl1.TableDescriptor.Columns;
//gridGroupingControl1.
//if (col.Count == 0)
// col = this.gridDataBoundGrid1.Binder.InternalColumns;

int nCols = col.Count;
string[] a = new string[nCols];
int i = 0;
foreach (GridColumnDescriptor c in col)
a[i++] = c.MappingName;

formatter.Serialize(stream, a);
formatter.Serialize(stream, gridGroupingControl1.TableControl.Model.ColWidths.Dictionary);
//formatter.Serialize(stream, this.gridDataBoundGrid1.Model.ColWidths.Dictionary);
stream.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}


I have just commented one if statement. I am not sure if that is creating problem. Please help me.

Thanks,
Santosh

Santosh U
Replied On September 5, 2009 06:38 AM UTC

Hi All,

I could achieve this by using Pedro' example,
Thanks Pedro.

Regards,
Santosh U

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

;