New to Telerik UI for WinForms? Start a free 30-day trial
Save and Load Layout
Updated over 1 year ago
Save/Load layout functionality gives your application the opportunity to preserve RadDiagram's shapes and restore them later. The whole shapes' data is written in a XML file.
Here is a sample demonstrating how you can save the layout to a file:
Save Layout
Save Layout
C#
string s = "default.xml";
System.Windows.Forms.SaveFileDialog dialog = new System.Windows.Forms.SaveFileDialog();
dialog.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*";
dialog.Title = "Select a xml file";
if (dialog.ShowDialog() == DialogResult.OK)
{
s = dialog.FileName;
}
this.radDiagram1.SaveToFile(s);
You can use the RadDiagram.Save method in case you need just the string representation of the XML data.
Load Layout
Here is a sample demonstrating how you can load the layout from a file:
Load Layout
C#
string s = "default.xml";
System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
dialog.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*";
dialog.Title = "Select a xml file";
if (dialog.ShowDialog() == DialogResult.OK)
{
s = dialog.FileName;
}
this.radDiagram1.LoadFromFile(s);
You can use the RadDiagram.Load method in order to load data from a string representation of the XML data.