Home / Community & Support / Knowledge Base / RadControls for WinForms / GridView / Save and Load RadGridView's layout

Save and Load RadGridView's layout

Article Info

Rating: 5

Article information

Article relates to

 RadGridView   for WinForms

Created by

 Boyko Markov, Telerik

Last modified

 7/2/2008

Last modified by

 Boyko Markov



HOW-TO
Save and load RadGridView's layout

SOLUTION

To Save the current layout of RadGridView in xml format use the SaveLayout method. The only parameter you need to pass is the string containing the file name.
      
string s = "default.xml"
this.radGridView1.SaveLayout(s); 
      

In the following example we add a functionality to save the grid's layout into any xml file using the SaveFileDialog

string s = "default.xml";  
SaveFileDialog dialog = new SaveFileDialog(); 
dialog.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*";  
dialog.Title = "Select a xml file"
if (dialog.ShowDialog() == DialogResult.OK) 
  s = dialog.FileName; 
 
this.radGridView1.SaveLayout(s); 


To Load the layout a string argument containing the file name should be passed as a parameter to the LoadLayout method of RadGridView. Here is a sample code:

string s = "default.xml"
this.radGridView1.LoadLayout(s); 
 

Below is shown how to load any of the already saved xml files containing the grid's layout  definitions using the OpenFileDialog.

string s = "default.xml"
OpenFileDialog dialog = new OpenFileDialog(); 
dialog.Filter = 
"xml files (*.xml)|*.xml|All files (*.*)|*.*";  
dialog.Title = "Select a xml file"
if (dialog.ShowDialog() == DialogResult.OK) 
   s = dialog.FileName; 
 
this.radGridView1.LoadLayout(s); 
 



Comments

If you'd like to comment on this KB article, please, send us a Support Ticket.
Thank you!

Please Sign In to rate this article.