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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

StyleSheet with GridDataBoundGrid

Thread ID:





57105 Feb 26,2007 04:15 PM UTC Feb 26,2007 05:42 PM UTC WinForms 1
Tags: GridControl
Martin Bonneville
Asked On February 26, 2007 04:15 PM UTC


I have some grid in my application. I want to apply the same "style" on each.

How I can do that ?

Best regard,


Administrator [Syncfusion]
Replied On February 26, 2007 05:42 PM UTC

Hi Martin,

Share the style object:


If you want to serialize a style to disk and then load it from another grid, the serializable portion of the GridStyleInfo object is the Store member. You can serialize a style out and then load it back in. The gridControl.SaveXml() is used to save the (grid)GridModel object to the stream in XML format. The GridControl.InitializeFromXml() is used to recreate the GridControl with the data and property that was saved in the XML format.

// Save to xml file

// Load from file


The SaveBinary method is used to save the current GridModel object to a file in binary format. The filename can be specified with FileName. The LoadBinary method is used to recreate a GridModel object from a file that holds data in binary format. Here is a code snippet.

//write out col2’s style

SaveBinary(@"C:\temp.sty", this.gridControl1.ColStyles[2]);

public void SaveBinary(string fileName, GridStyleInfo style)
Stream s = File.OpenWrite(fileName);
BinaryFormatter b = new BinaryFormatter();
b.Serialize(s, style.Store);

//set grid2’s col1 to use the saved style
this.gridControl2.ColStyles[1] = new GridStyleInfo(LoadBinary(@"C:\temp.sty"));

public GridStyleInfoStore LoadBinary(string fileName)
GridStyleInfoStore t = null;
Stream s = File.OpenRead(fileName);
BinaryFormatter b = new BinaryFormatter();
object obj = b.Deserialize(s);
t = obj as GridStyleInfoStore;
//t.fileName = fileName;
return t;

Share the GridModel :

If you want two grid’s to share one grid model, then when you create the second grid, you pass the first grid’s model as an argument in the constructor.

this.gridControl2 = new GridControl( this.gridControl1.Model );

This will force to two grid’s to be exactly the same.

Share the GridTableStyle :

If you want the table style of one grid to be the same as the table style of another, you would just set them equal. But the tablestyle of an exisiting grid may have been cached to make drawing quicker, so you might need to call ResetVolatileData to force the grid to reload cached obejcts.

this.gridControl2.TableStyle = this.gridControl1.TableStyle;

Best Regards,


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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