Skip to main content
A newer version of this page is available. .

How to: Save the Control Layout to a Stream and Then Restore It

The following sample code demonstrates the way in which to save the control layout to a stream and then restore it. The NavBarControl.SaveToStream and NavBarControl.RestoreFromStream methods are used for this purpose.

The image below displays two NavBarControl controls before and after code execution. Note that the second control is initially empty (it doesn’t contain any groups and items). Layout information for the first control is saved to a stream. The second control restores it. Note that only the layout of groups and links is saved.

SaveRestore

Imports System.IO

FileStream outFile = new FileStream("C:\\NavBarLayout", FileMode.Create);
navBarControl1.SaveToStream(outFile);
outFile.Close();
FileStream inFile = new FileStream("C:\\NavBarLayout", FileMode.Open);
navBarControl2.RestoreFromStream(inFile);
inFile.Close();