property Tree.ToTemplate ([DefaultTemplate as Variant]) as String
Generates the control's template.

 TypeDescription 
   DefaultTemplate as Variant A String expression that indicates the default format used to define the control's template at runtime, or a string expression that indicates the path to the file being used to define the default template ( like c:\temp\teml.bin ). If it is missing ( by default ), the control's uses the default implementation ( listed bellow ) to define the control's template, at runtime. Each line in the DefaultTemplate parameter, defines a property or an instruction to generate the template.  
   String A String expression that indicates the control's template.  
Use the ToTemplate property to save the control's content to a template string. The ToTemplate property saves the control's properties based on the default template. Use the ToTemplate property to copy the control's content to another instance. The ToTemplate property can save pictures, icons, binary arrays, objects, collections, and so on based on the DefaultTemplate parameter.

The DefaultTemplate parameter indicates the format of the template being used to generate the control's template at runtime. If the DefaultTemplate parameter is missing, the control's uses its default template listed bellow. The DefaultTemplate parameter defines the list of properties and instructions that generates the control's template. Remove the properties and objects, in the default template, that you don't need in the generated template script. Use the Template property to apply the template to the control. Use the Template property to execute code by passing instructions as a string ( template string ). The Template script is composed by lines of instructions. Instructions are separated by "\n\r" ( newline) characters. The Template format contains a list of instructions that loads data and change properties for the objects in the control. Use the AllowCopyTemplate property to copy the control's content to the clipboard, in template format, using the the Shift + Ctrl + Alt + Insert sequence. 

The time to generate the control's template depends on:

For instance, let's say that we have the following DefaultTemplate parameter:

Appearance = 2
AllowEdit = -1

In this case the ToTemplate property generates code only for the properties Appearance and AllowEdit, if they were changed to a different value. 

If the DefaultTemplate parameters looks like:

Appearance
AllowEdit = -1

The ToTemplate property always generates code for the Appearance property, and it generates code for the AutoEdit property only if this is changed to a value different than -1. If the DefaultTemplate parameter is missing, the control uses its default template to generate the template format. The default template format looks like follow, and it may differ from a version to another.

For instance, let's say that we need to save the layout ( size and position ) of the columns ( 4 columns ) in the control. In this case, we need to define a new DefaultTemplate parameter that includes only the Columns section as follows:

The indentation in the template is very important, so please make sure that you respect the indentation of the inside objects and properties. If an item in the template is indented it is related to the parent item/object. 


Send comments on this topic.
1999-2017 Exontrol.COM, Software. All rights reserved.