Version

Save and Load Layouts

Introduced in v3 of the WinTree™ is the ability to save and load control layouts. The information stored by the layout includes everything that affects the appearance of the tree: The Nodes collection, the Override object and sub-objects, and all related properties.

Tree layouts may be saved in either binary or XML format. The binary format is more space-efficient, while the XML format provides greater inter-operability with other technologies. You can choose to serialize the layout to a storage stream or write it into a file on disk. When you load a layout file into the Tree, you should use the method that corresponds to the method used to save the file. If you use the SaveAsBinary method to create the layout file, you should use the LoadFromBinary method to load that file and restore the saved layout. Similarly, files created with the SaveAsXml method should be restored with the LoadFromXml method.

Use the following code to write the Tree layout in Xml format into a local file in a specific location.

In Visual Basic:

Private Sub btnSave_Click(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles btnSave.Click
	Me.UltraTree1.SaveAsXml("UWTree1.xml")
End Sub

In C#:

private void btnSave_Click(object sender, EventArgs e)
{
	this.ultraTree1.SaveAsXml("UWTree1.xml");
}
Note
Note

If using binary Save or Load methods, there is no pre-defined file extension for binary layout files. You can choose whichever file extension you think is appropriate, but be sure to use it consistently.

Use the following code to load the previously saved file back into the Tree.

In Visual Basic:

Private Sub btnLoad_Click(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles btnLoad.Click
	Me.UltraTree1.LoadFromXml("UWTree1.xml")
End Sub

In C#:

private void btnLoad_Click(object sender, EventArgs e)
{
	this.ultraTree1.LoadFromXml("UWTree1.xml");
}