HeaderPane
Main
Hide
Share Link
Print

Saving and Loading

The list of a combo box, with its columns, items, headers, footers and settings, and the properties of the combo box can be saved as an XML document and loaded again.

The SftBox.GetContents method returns the contents of a combo box as an XML document, and the SftBox.SetContents method loads the contents of a combo box from such a document. The PersistContentsEnum enumeration defines what is saved or loaded: the items (PersistContentsEnum.ItemsOnly), headers (PersistContentsEnum.HeadersOnly) or footers (PersistContentsEnum.FootersOnly) of the list, all three (PersistContentsEnum.Contents), the properties of the list and of the combo box (PersistContentsEnum.Props) or everything (PersistContentsEnum.All). The selection and the text of the combo box are not part of its contents.

C#

// save
XmlDocument doc = SftBox.GetContents(sftBox1, PersistContentsEnum.All);
doc.Save(fileName);

// load
XmlDocument saved = new XmlDocument();
saved.Load(fileName);
SftBox.SetContents(sftBox1, saved, PersistContentsEnum.All);

VB

' save
Dim doc As XmlDocument = SftBox.GetContents(SftBox1, PersistContentsEnum.All)
doc.Save(fileName)

' load
Dim saved As New XmlDocument()
saved.Load(fileName)
SftBox.SetContents(SftBox1, saved, PersistContentsEnum.All)

The ItemClass.TagString and CellBaseClass.TagString strings of items and cells are saved, the objects in their TagObjects properties are not.

Forms

The list defined at design time is saved with the form by the Visual Studio designer, using the control's Contents property. Applications do not use this property; they save and load contents using the GetContents and 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 SftBox/NET with .NET 10).