The properties of an SftMask control, including its mask, its calculator and autocomplete settings and its colors, can be saved as an XML document and loaded again, for example to keep a user's settings for a field.
The SftMask.GetContents method returns the properties of a control as an XML document, and the SftMask.SetContents method loads them into a control from such a document. The PersistContentsEnum enumeration defines what is saved or loaded: PersistContentsEnum.Props and PersistContentsEnum.All both save and load the control's properties, including the spin steps (SftMask.SpinAccelerations property). The contents of the field and the font are not part of the saved properties. SftMask.SetContents sets the properties the document does not contain to their defaults, so the control looks and behaves exactly as the saved one did.
C#
// save XmlDocument doc = SftMask.GetContents(sftMask1, PersistContentsEnum.Props); doc.Save(fileName); // load XmlDocument saved = new XmlDocument(); saved.Load(fileName); SftMask.SetContents(sftMask2, saved, PersistContentsEnum.Props);
VB
' save Dim doc As XmlDocument = SftMask.GetContents(SftMask1, PersistContentsEnum.Props) doc.Save(fileName) ' load Dim saved As New XmlDocument() saved.Load(fileName) SftMask.SetContents(SftMask2, saved, PersistContentsEnum.Props)
The Visual Studio designer saves the properties of a control with the form, and saves the SftMask.Contents property in the form's resource (.resx) file for the license information. Applications do not use this property; they save and load properties using the GetContents and SetContents methods.
The saved properties hold no images or fonts, so a document saved by a .NET 10 application loads in .NET Framework applications and the other way around (see Using SftMask/NET with .NET 10).