HeaderPane
Main
Hide
Share Link
Print

Saving and Loading Tabs

The tabs of a SftTabs/NET control and the control's properties can be saved as an XML document and loaded again, for example to restore the tabs a user had open.

The SftTabs.GetContents method returns the contents of a control as an XML document and the SftTabs.SetContents method loads the contents of a control from such a document. The PersistContentsEnum enumeration defines what is saved or loaded: the tabs, the control's properties or both.

C#

// save
XmlDocument doc = SftTabs.GetContents(sftTabs1, PersistContentsEnum.TabsOnly);
doc.Save(fileName);

// load
XmlDocument saved = new XmlDocument();
saved.Load(fileName);
SftTabs.SetContents(sftTabs1, saved, PersistContentsEnum.TabsOnly);

VB

' save
Dim doc As XmlDocument = SftTabs.GetContents(SftTabs1, PersistContentsEnum.TabsOnly)
doc.Save(fileName)

' load
Dim saved As New XmlDocument()
saved.Load(fileName)
SftTabs.SetContents(SftTabs1, saved, PersistContentsEnum.TabsOnly)

A saved tab includes its parts, such as text and images, and its properties. The image list of a tab (TabClass.ImageList property) and its TabClass.Tag object are not saved.

The tab pages and the controls they host are not part of the saved contents. When tabs are loaded, the existing tabs are replaced and the pages stay with the tabs at the same positions.

Forms

The tabs defined at design-time are saved with the form by the Visual Studio designer, using the control's SftTabs.Contents property. Applications do not use this property; they save and load tabs using the SftTabs.GetContents and SftTabs.SetContents methods.

.NET Framework and .NET 10

In .NET Framework applications, images and fonts in the contents are saved with the BinaryFormatter. .NET 10 no longer includes it, so .NET 10 applications save images as image files and fonts by their name, size, style, unit and character set. Contents saved by a .NET 10 application load in .NET 10 and .NET Framework applications; contents saved by a .NET Framework application load in a .NET 10 application only if they contain no images or fonts (see Using SftTabs/NET with .NET 10).