HeaderPane
Main
Hide
Share Link
Print

Saving and Loading

The special dates and the properties of an SftDate or SftCalendar control can be saved as an XML document and loaded again, for example to keep a user's holidays and calendar settings.

The SftDate.GetContents and SftCalendar.GetContents methods return the contents of a control as an XML document, and the SftDate.SetContents and SftCalendar.SetContents methods load the contents of a control from such a document. The PersistContentsEnum enumeration defines what is saved or loaded: the special dates (PersistContentsEnum.SpecialDates), the control's properties including the calendar settings (PersistContentsEnum.Props) or both (PersistContentsEnum.All). The value of a control is not part of its contents.

C#

// save
XmlDocument doc = SftCalendar.GetContents(sftCalendar1, PersistContentsEnum.SpecialDates);
doc.Save(fileName);

// load
XmlDocument saved = new XmlDocument();
saved.Load(fileName);
SftCalendar.SetContents(sftCalendar1, saved, PersistContentsEnum.SpecialDates);

VB

' save
Dim doc As XmlDocument = SftCalendar.GetContents(SftCalendar1, PersistContentsEnum.SpecialDates)
doc.Save(fileName)

' load
Dim saved As New XmlDocument()
saved.Load(fileName)
SftCalendar.SetContents(SftCalendar1, saved, PersistContentsEnum.SpecialDates)

The SpecialDateClass.Tag object of a special date is not saved.

Forms

The special dates defined at design time are 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 SftDate/NET with .NET 10).