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.

[0 = BeginUpdate]
VisualAppearance
	[0 = Add(%ID,%CONTENT)]
[1 = Images(%VALUE)]
AllowEdit = 0
Appearance = 2
ASCIILower = "abcdefghijklmnopqrstuvwxyzüéâäàåçêëèïîìôöòûùáíóúñ"
ASCIIUpper = "ABCDEFGHIJKLMNOPQRSTUVWXYZÜÉÂÄÀÅÇÊËÈÏÎÌÔÖÒÛÙÁÍÓÚÑ"
AutoSearch = -1
BackColor = 2147483653
BackColorAlternate = 0
BackColorHeader = 2147483663
BackColorLevelHeader = 2147483663
BackColorLock = 2147483653
BackColorSortBar = 2147483664
BackColorSortBarCaption = 2147483663
Background(3) = 0
Background(2) = 0
Background(8) = 0
Background(12) = 0
Background(11) = 0
Background(14) = 0
Background(13) = 0
Background(10) = 0
Background(9) = 0
Background(1) = 0
Background(0) = 0
Background(20) = 0
Background(21) = 0
CheckImage(0) = 0
CheckImage(1) = 0
CheckImage(2) = 0
ColumnAutoResize = -1
ColumnsAllowSizing = 0
ContinueColumnScroll = -1
CountLockedColumns = 0
DefaultItemHeight = 18
Description(0) = "(All)"
Description(11) = " and "
Description(1) = "(Blanks)"
Description(19) = "(Checked)"
Description(12) = "Date:"
Description(17) = "January February March April May June July August September October November December"
Description(15) = "Date"
Description(13) = "to"
Description(16) = "Today"
Description(14) = "You can filter the items into a given interval of dates. For instance, you can filter all items dated before a specified date ( to 2/13/2004 ), or all items dated after a date ( Feb 13 2004 to ) or all items that are in a given interval ( 2/13/2004 to 2/13/2005 )."
Description(18) = "S M T W T F S"
Description(3) = "Filter For:"
Description(8) = "A pattern filter may contain the wild card characters '?' for any single character, '*' for zero or more occurrences of any character, '#' for any digit character, '|' determines the options in the pattern. For instance: '1*|2*' specifies all items that start with '1' or '2'. If the filter is of numeric type you can filter numbers giving numeric rules. For instance, ">10 <100" filter indicates all numbers greater than 10 and less than 100."
Description(4) = "Filter"
Description(9) = "IsBlank"
Description(21) = "IsChecked"
Description(10) = "not IsBlank"
Description(22) = "not IsChecked"
Description(2) = "(NonBlanks)"
Description(5) = "Pattern/Numeric Filter"
Description(7) = "You can select multiple filter items as many as you like by keeping the CTRL key pressed. Start typing characters if you like to enter a filter as a pattern that may include wild card characters like *,? or #. Press ENTER key to filter the items using the typed pattern. If the filter is of numeric type you can filter numbers giving numeric rules. For instance, ">10 <100" filter indicates all numbers greater than 10 and less than 100."
Description(6) = "You can select multiple filter items as many as you like by keeping the CTRL key pressed. "
Description(20) = "(Unchecked)"
DetectAddNew = 0
DrawGridLines = 0
Enabled = -1
ExpandOnDblClick = -1
ExpandOnKeys = -1
ExpandOnSearch = 0
FilterBarBackColor = 2147483663
FilterBarCaption = ""
FilterBarDropDownHeight = 0.5
FilterBarFont
	Bold = -1
	Charset = 0
	Italic = 0
	Name = "Arial"
	Size = 8.25
	Strikethrough = 0
	Underline = 0
	Weight = 700
FilterBarForeColor = 2147483656
FilterBarHeight = -1
FilterInclude = 0
Font
	Bold = 0
	Charset = 0
	Italic = 0
	Name = "Arial"
	Size = 8.25
	Strikethrough = 0
	Underline = 0
	Weight = 400
ForeColor = 2147483656
ForeColorHeader = 2147483656
ForeColorLock = 2147483656
ForeColorSortBar = 2147483664
FullRowSelect = -1
GridLineColor = 8949832
HasButtons = -1
HasButtonsCustom(0) = 0
HasButtonsCustom(-1) = 0
HasLines = -1
HeaderAppearance = 3
HeaderHeight = 18
HeaderVisible = -1
HideSelection = 0
HyperLinkColor = 16737585
Indent = 22
ItemsAllowSizing = 0
LinesAtRoot = 0
MarkSearchColumn = -1
OLEDropMode = 0
PictureDisplay = 48
[255 = Picture = LoadPicture("%VALUE")]
PictureDisplayLevelHeader = 48
[256 = PictureLevelHeader = LoadPicture("%VALUE")]
RadioImage(0) = 0
RadioImage(-1) = 0
RClickSelect = 0
ScrollBars = 3
ScrollBySingleLine = 0
SearchColumnIndex = 0
SelBackColor = 2147483661
SelBackMode = 0
SelectColumn = 0
SelectColumnIndex = 0
SelectColumnInner = 0
SelForeColor = 2147483662
SelLength = -1
SelStart = 0
ShowFocusRect = -1
ShowImageList = 0
ShowLockedItems = -1
SingleSel = -1
SingleSort = -1
SortBarCaption = "Drag a column header here to sort by that column."
SortBarColumnWidth = -96
SortBarHeight = 18
SortBarVisible = 0
SortOnClick = -1
ToolTipDelay = 500
ToolTipPopDelay = 5000
ToolTipWidth = 196
TreeColumnIndex = 0
UseTabKey = -1
Columns
	_NewEnum = "%Caption"
		Alignment = 0
		AllowDragging = -1
		AllowSizing = -1
		AllowSort = -1
		AutoSearch = 0
		[AutoWidth = 0]
		Caption = ""
		Data
		Def(4)
		Def(3) = 0
		Def(17) = 0
		Def(5)
		Def(2) = 0
		Def(0) = 0
		Def(1) = 0
		Def(16) = -1
		DefaultSortOrder = 0
		DisplayFilterButton = 0
		DisplayFilterDate = 0
		DisplayFilterPattern = -1
		DisplaySortIcon = -1
		Enabled = -1
		Filter = ""
		FilterBarDropDownWidth = 1
		FilterList = 0
		FilterType = 0
		FireFormatColumn = 0
		HeaderAlignment = 0
		HeaderBold = 0
		HeaderImage = 0
		HeaderImageAlignment = 0
		HeaderItalic = 0
		HeaderStrikeOut = 0
		HeaderUnderline = 0
		HTMLCaption = ""
		[Index = 0]
		Key = ""
		LevelKey
		MaxWidthAutoResize = -1
		MinWidthAutoResize = 0
		PartialCheck = 0
		Position
		SortOrder = 0
		SortPosition = -1
		SortType = 0
		ToolTip = "..."
		Visible = -1
		Width
		WidthAutoResize = 0
Items
	PathSeparator = "\"
	LockedItemCount(0) = 0
	LockedItemCount(2) = 0
	[1 = %H = LockedItem(%A,%I)]
		[10 = CellCaption(%H,%C) = %VALUE]
		[11 = CellImage(%H,%C) = %VALUE]
		[12 = CellSingleLine(%H,%C) = %VALUE]
		[13 = CellCaptionFormat(%H,%C) = %VALUE]
		[14 = CellFormatLevel(%H,%C) = %VALUE]
		[15 = CellHasCheckBox(%H,%C) = %VALUE]
		[16 = CellHasRadioButton(%H,%C) = %VALUE]
		[17 = CellState(%H,%C) = %VALUE]
		[18 = CellToolTip(%H,%C) = %VALUE]
		[19 = CellHasButton(%H,%C) = %VALUE]
		[20 = CellButtonAutoWidth(%H,%C) = %VALUE]
		[21 = CellEnabled(%H,%C) = %VALUE]
		[23 = CellHAlignment(%H,%C) = %VALUE]
		[24 = CellVAlignment(%H,%C) = %VALUE]
		[25 = CellMerge(%H,%C) = %VALUE]
		[26 = CellBold(%H,%C) = %VALUE]
		[27 = CellItalic(%H,%C) = %VALUE]
		[28 = CellUnderline(%H,%C) = %VALUE]
		[29 = CellStrikeOut(%H,%C) = %VALUE]
		[30 = CellForeColor(%H,%C) = %VALUE]
		[31 = CellBackColor(%H,%C) = %VALUE]
		[32 = CellPicture(%H,%C) = %VALUE]
		[33 = CellPictureWidth(%H,%C) = %VALUE]
		[34 = CellPictureHeight(%H,%C) = %VALUE]
		[1000 = ExpandItem(%H) = %VALUE]
		[1001 = SelectItem(%H) = %VALUE]
		[1002 = ItemHeight(%H) = %VALUE]
		[1003 = ItemDivider(%H) = %VALUE]
		[1004 = ItemDividerLine(%H) = %VALUE]
		[1005 = ItemDividerLineAlignment(%H) = %VALUE]
		[1006 = ItemHasChildren(%H) = %VALUE]
		[1007 = ItemBold(%H) = %VALUE]
		[1008 = ItemItalic(%H) = %VALUE]
		[1009 = ItemUnderline(%H) = %VALUE]
		[1010 = ItemStrikeOut(%H) = %VALUE]
		[1011 = ItemForeColor(%H) = %VALUE]
		[1012 = ItemBackColor(%H) = %VALUE]
	[0 = %H = %ADD(%VALUE)]
		[10 = CellCaption(%H,%C) = %VALUE]
		[11 = CellImage(%H,%C) = %VALUE]
		[12 = CellSingleLine(%H,%C) = %VALUE]
		[13 = CellCaptionFormat(%H,%C) = %VALUE]
		[14 = CellFormatLevel(%H,%C) = %VALUE]
		[15 = CellHasCheckBox(%H,%C) = %VALUE]
		[16 = CellHasRadioButton(%H,%C) = %VALUE]
		[17 = CellState(%H,%C) = %VALUE]
		[18 = CellToolTip(%H,%C) = %VALUE]
		[19 = CellHasButton(%H,%C) = %VALUE]
		[20 = CellButtonAutoWidth(%H,%C) = %VALUE]
		[21 = CellEnabled(%H,%C) = %VALUE]
		[23 = CellHAlignment(%H,%C) = %VALUE]
		[24 = CellVAlignment(%H,%C) = %VALUE]
		[25 = CellMerge(%H,%C) = %VALUE]
		[26 = CellBold(%H,%C) = %VALUE]
		[27 = CellItalic(%H,%C) = %VALUE]
		[28 = CellUnderline(%H,%C) = %VALUE]
		[29 = CellStrikeOut(%H,%C) = %VALUE]
		[30 = CellForeColor(%H,%C) = %VALUE]
		[31 = CellBackColor(%H,%C) = %VALUE]
		[32 = CellPicture(%H,%C) = %VALUE]
		[33 = CellPictureWidth(%H,%C) = %VALUE]
		[34 = CellPictureHeight(%H,%C) = %VALUE]
		[1000 = ExpandItem(%H) = %VALUE]
		[1001 = SelectItem(%H) = %VALUE]
		[1002 = ItemHeight(%H) = %VALUE]
		[1003 = ItemDivider(%H) = %VALUE]
		[1004 = ItemDividerLine(%H) = %VALUE]
		[1005 = ItemDividerLineAlignment(%H) = %VALUE]
		[1006 = ItemHasChildren(%H) = %VALUE]
		[1007 = ItemBold(%H) = %VALUE]
		[1008 = ItemItalic(%H) = %VALUE]
		[1009 = ItemUnderline(%H) = %VALUE]
		[1010 = ItemStrikeOut(%H) = %VALUE]
		[1011 = ItemForeColor(%H) = %VALUE]
		[1012 = ItemBackColor(%H) = %VALUE]
		[1013 = SelectableItem(%H) = %VALUE]
[2 = ApplyFilter]
ScrollPos(0) = 0
ScrollPos(-1) = 0
[0 = EndUpdate]

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:

Columns
	Item(0)
		Position
		Width = 64
	Item(1)
		Position
		Width = 64
	Item(2)
		Position
		Width = 64
	Item(3)
		Position
		Width = 64

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.