The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
ADAdministrator Syncfusion Team February 26, 2007 05:42 PM UTC
Hi Martin,
Share the style object:
Technique1:
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 grid1.SaveXml(@"c:\mygrid.xml");
// Load from file grid2.InitializeFromXml(@"c:\mygrid.xml");
Technique2:
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.
public void SaveBinary(string fileName, GridStyleInfo style) { Stream s = File.OpenWrite(fileName); BinaryFormatter b = new BinaryFormatter(); b.Serialize(s, style.Store); s.Close(); }
//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); try { BinaryFormatter b = new BinaryFormatter(); object obj = b.Deserialize(s); t = obj as GridStyleInfoStore; //t.fileName = fileName; } finally { s.Close(); } 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.