property NETHostObject.Template as String
Executes the x-script code.

TypeDescription
String A String expression that specifies the x-script/template code to be executed.
Use the Template/Item property to get/set properties / fields / parameters, invoke methods of the hosting /NET framework Value, using the x-script code. The Item property does exactly the same thing as Template call, excepts that it returns the TemplateResult property. For instance, using the Template/Item property you can change the hosting control's background color, add nodes, and so on. Prior to Template/Item call, you can invoke the SetTemplateDef to define values from your code to Template's code ( TemplateDef variables ).

in VB/NET under the .NET Framework, you use a code like follows to add nodes to a TreeView control:

With TreeView1
    With .Nodes.Add("Root 1")
        .Nodes.Add("Child 1")
        With .Nodes.Add("Child 2")
            .Nodes.Add("Sub-Child 2.1")
            .Nodes.Add("Sub-Child 2.2")
            .Nodes.Add("Sub-Child 2.3")
            .Expand()
        End With
        .Nodes.Add("Child 3")
        .Expand()
    End With
    With .Nodes.Add("Root 2")
        .Nodes.Add("Child 1")
        .Nodes.Add("Child 2")
        .Nodes.Add("Child 3")
    End With
End With

while on VB using the NETHost control you should use a code like:

With NETHost1
    .AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
    .AssemblyName = "System.Windows.Forms.TreeView"
    With .Host
        With .Item("Nodes.Add(`Root 1`)")
            .Template = "Nodes.Add(`Child 1`)"
            With .Item("Nodes.Add(`Child 2`)")
                .Template = "Nodes.Add(`Sub-Child 2.1`)"
                .Template = "Nodes.Add(`Sub-Child 2.2`)"
                .Template = "Nodes.Add(`Sub-Child 2.3`)"
                .Template = "Expand()"
            End With
            .Template = "Nodes.Add(`Child 3`)"
            .Template = "Expand()"
        End With
        With .Item("Nodes.Add(`Root 2`)")
            .Template = "Nodes.Add(`Child 1`)"
            .Template = "Nodes.Add(`Child 2`)"
            .Template = "Nodes.Add(`Child 3`)"
        End With
    End With
End With

The Template/x-script syntax in BNF notation is defined like follows:

<x-script> := <lines>
<lines> := <line>[<eol> <lines>] | <block>
<block> := <call> [<eol>] { [<eol>] <lines> [<eol>] } [<eol>]
<eol> := ";" | "\r\n"
<line> := <dim> | <createobject> | <call> | <set> | <comment>
<dim> := "DIM" <variables>
<variables> := <variable> [, <variables>]
<variable> := "ME" | <identifier>
<createobject> := "CREATEOBJECT(`"<type>"`)"
<call> := <variable> | <property> | <variable>"."<property> | <createobject>"."<property>
<property> := [<property>"."]<identifier>["("<parameters>")"]
<set> := <call> "=" <value>
<property> := <identifier> | <identifier>"("[<parameters>]")"
<parameters> := <value> [","<parameters>]
<value> := <boolean> | <number> | <color> | <date> | <string> | <createobject> | <call>
<boolean> := "TRUE" | "FALSE"
<number> := "0X"<hexa> | ["-"]<integer>["."<integer>]
<digit10> := 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
<digit16> := <digit10> | A | B | C | D | E | F
<integer> := <digit10>[<integer>]
<hexa> := <digit16>[<hexa>]
<color> := "RGB("<integer>","<integer>","<integer>")"
<date> := "#"<integer>"/"<integer>"/"<integer>" "[<integer>":"<integer>":"<integer>"]"#"
<string> := '"'<text>'"' | "`"<text>"`"
<comment> := "'"<text>

where:

<identifier> indicates an identifier of the variable, property or method, and should start with a letter.
<type> indicates the type the CreateObject function creates, as the assembly-qualified name of the type to create.
<text> any string of characters

The Template / x-script is composed by lines of instructions. Instructions are separated by "\r\n" ( new line characters ) or ";" character. The TemplateThrowError property specifies whether the control fires an exception/error when the Template call fails. The TemplateError / TemplateException gets the error if the Template calls fails. The TemplateResult property returns the result of the last instruction into a Template call, as a NETObjectTemplate object.

An x-script instruction/line can be one of the following:

where

The x-script uses constant expressions as follows:

Also , the template or x-script code supports general functions as follows:

The following samples shows how you can use the Template and TemplateResult properties:

VBA (MS Access, Excell...)

With NETHost1
	.AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
	.AssemblyName = "System.Windows.Forms.TreeView"
	With .Host
		.Template = "Nodes.Add(`Root 1`)"
		With .TemplateResult
			.Template = "Nodes.Add(`Child 1`)"
			.Template = "Nodes.Add(`Child 2`)"
			.Template = "Expand()"
		End With
	End With
End With

VB6

With NETHost1
	.AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
	.AssemblyName = "System.Windows.Forms.TreeView"
	With .Host
		.Template = "Nodes.Add(`Root 1`)"
		With .TemplateResult
			.Template = "Nodes.Add(`Child 1`)"
			.Template = "Nodes.Add(`Child 2`)"
			.Template = "Expand()"
		End With
	End With
End With

VB.NET

With Exnethost1
	.AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
	.AssemblyName = "System.Windows.Forms.TreeView"
	With .Host
		.Template = "Nodes.Add(`Root 1`)"
		With .TemplateResult
			.Template = "Nodes.Add(`Child 1`)"
			.Template = "Nodes.Add(`Child 2`)"
			.Template = "Expand()"
		End With
	End With
End With

VB.NET for /COM

With AxNETHost1
	.AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
	.AssemblyName = "System.Windows.Forms.TreeView"
	With .Host
		.Template = "Nodes.Add(`Root 1`)"
		With .TemplateResult
			.Template = "Nodes.Add(`Child 1`)"
			.Template = "Nodes.Add(`Child 2`)"
			.Template = "Expand()"
		End With
	End With
End With

C++

/*
	Copy and paste the following directives to your header file as
	it defines the namespace 'exontrol_NETHost' for the library: 'Exontrol NETHost ActiveX Component'

	#import <exontrol.NETHost.tlb>
*/
exontrol_NETHost::INETHostCtrlPtr spNETHost1 = GetDlgItem(IDC_NETHOST1)->GetControlUnknown();
spNETHost1->PutAssemblyLocation(L"C:\\Windows\\assembly\\GAC_MSIL\\System.Windows.Forms\\2.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll");
spNETHost1->PutAssemblyName(L"System.Windows.Forms.TreeView");
exontrol_NETHost::INETHostObjectPtr var_NETHostObject = spNETHost1->GetHost();
	var_NETHostObject->PutTemplate(L"Nodes.Add(`Root 1`)");
	exontrol_NETHost::INETObjectTemplatePtr var_NETHostObject1 = var_NETHostObject->GetTemplateResult();
		var_NETHostObject1->PutTemplate(L"Nodes.Add(`Child 1`)");
		var_NETHostObject1->PutTemplate(L"Nodes.Add(`Child 2`)");
		var_NETHostObject1->PutTemplate(L"Expand()");

C++ Builder

NETHost1->AssemblyLocation = L"C:\\Windows\\assembly\\GAC_MSIL\\System.Windows.Forms\\2.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll";
NETHost1->AssemblyName = L"System.Windows.Forms.TreeView";
Exontrol_nethost_tlb::INETHostObjectPtr var_NETHostObject = NETHost1->Host;
	var_NETHostObject->Template = L"Nodes.Add(`Root 1`)";
	Exontrol_nethost_tlb::INETObjectTemplatePtr var_NETHostObject1 = var_NETHostObject->TemplateResult;
		var_NETHostObject1->Template = L"Nodes.Add(`Child 1`)";
		var_NETHostObject1->Template = L"Nodes.Add(`Child 2`)";
		var_NETHostObject1->Template = L"Expand()";

C#

exnethost1.AssemblyLocation = "C:\\Windows\\assembly\\GAC_MSIL\\System.Windows.Forms\\2.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll";
exnethost1.AssemblyName = "System.Windows.Forms.TreeView";
exontrol_NETHost.NETHostObject var_NETHostObject = exnethost1.Host;
	var_NETHostObject.Template = "Nodes.Add(`Root 1`)";
	exontrol_NETHost.NETHostObject var_NETHostObject1 = var_NETHostObject.TemplateResult;
		var_NETHostObject1.Template = "Nodes.Add(`Child 1`)";
		var_NETHostObject1.Template = "Nodes.Add(`Child 2`)";
		var_NETHostObject1.Template = "Expand()";

JScript/JavaScript

<BODY onload="Init()">
<OBJECT CLASSID="clsid:FDCBA3E0-4E2F-4DC7-B073-EAA7BD7EC565" id="NETHost1"></OBJECT>

<SCRIPT LANGUAGE="JScript">
function Init()
{
	NETHost1.AssemblyLocation = "C:\\Windows\\assembly\\GAC_MSIL\\System.Windows.Forms\\2.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll";
	NETHost1.AssemblyName = "System.Windows.Forms.TreeView";
	var var_NETHostObject = NETHost1.Host;
		var_NETHostObject.Template = "Nodes.Add(`Root 1`)";
		var var_NETHostObject1 = var_NETHostObject.TemplateResult;
			var_NETHostObject1.Template = "Nodes.Add(`Child 1`)";
			var_NETHostObject1.Template = "Nodes.Add(`Child 2`)";
			var_NETHostObject1.Template = "Expand()";
}
</SCRIPT>
</BODY>

VBScript

<BODY onload="Init()">
<OBJECT CLASSID="clsid:FDCBA3E0-4E2F-4DC7-B073-EAA7BD7EC565" id="NETHost1"></OBJECT>

<SCRIPT LANGUAGE="VBScript">
Function Init()
	With NETHost1
		.AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
		.AssemblyName = "System.Windows.Forms.TreeView"
		With .Host
			.Template = "Nodes.Add(`Root 1`)"
			With .TemplateResult
				.Template = "Nodes.Add(`Child 1`)"
				.Template = "Nodes.Add(`Child 2`)"
				.Template = "Expand()"
			End With
		End With
	End With
End Function
</SCRIPT>
</BODY>

C# for /COM

axNETHost1.AssemblyLocation = "C:\\Windows\\assembly\\GAC_MSIL\\System.Windows.Forms\\2.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll";
axNETHost1.AssemblyName = "System.Windows.Forms.TreeView";
exontrol_NETHost.NETHostObject var_NETHostObject = axNETHost1.Host;
	var_NETHostObject.Template = "Nodes.Add(`Root 1`)";
	exontrol_NETHost.NETHostObject var_NETHostObject1 = var_NETHostObject.TemplateResult;
		var_NETHostObject1.Template = "Nodes.Add(`Child 1`)";
		var_NETHostObject1.Template = "Nodes.Add(`Child 2`)";
		var_NETHostObject1.Template = "Expand()";

X++ (Dynamics Ax 2009)

public void init()
{
	COM com_NETHostObject,com_NETHostObject1;
	anytype var_NETHostObject,var_NETHostObject1;
	;

	super();

	exnethost1.AssemblyLocation("C:\\Windows\\assembly\\GAC_MSIL\\System.Windows.Forms\\2.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll");
	exnethost1.AssemblyName("System.Windows.Forms.TreeView");
	var_NETHostObject = exnethost1.Host(); com_NETHostObject = var_NETHostObject;
		com_NETHostObject.Template("Nodes.Add(`Root 1`)");
		var_NETHostObject1 = com_NETHostObject.TemplateResult(); com_NETHostObject1 = var_NETHostObject1;
			com_NETHostObject1.Template("Nodes.Add(`Child 1`)");
			com_NETHostObject1.Template("Nodes.Add(`Child 2`)");
			com_NETHostObject1.Template("Expand()");
}

Delphi 8 (.NET only)

with AxNETHost1 do
begin
	AssemblyLocation := 'C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll';
	AssemblyName := 'System.Windows.Forms.TreeView';
	with Host do
	begin
		Template := 'Nodes.Add(`Root 1`)';
		with TemplateResult do
		begin
			Template := 'Nodes.Add(`Child 1`)';
			Template := 'Nodes.Add(`Child 2`)';
			Template := 'Expand()';
		end;
	end;
end

Delphi (standard)

with NETHost1 do
begin
	AssemblyLocation := 'C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll';
	AssemblyName := 'System.Windows.Forms.TreeView';
	with Host do
	begin
		Template := 'Nodes.Add(`Root 1`)';
		with TemplateResult do
		begin
			Template := 'Nodes.Add(`Child 1`)';
			Template := 'Nodes.Add(`Child 2`)';
			Template := 'Expand()';
		end;
	end;
end

VFP

with thisform.NETHost1
	.AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
	.AssemblyName = "System.Windows.Forms.TreeView"
	with .Host
		.Template = "Nodes.Add(`Root 1`)"
		with .TemplateResult
			.Template = "Nodes.Add(`Child 1`)"
			.Template = "Nodes.Add(`Child 2`)"
			.Template = "Expand()"
		endwith
	endwith
endwith

dBASE Plus

local oNETHost,var_NETHostObject,var_NETHostObject1

oNETHost = form.Activex1.nativeObject
oNETHost.AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
oNETHost.AssemblyName = "System.Windows.Forms.TreeView"
var_NETHostObject = oNETHost.Host
	var_NETHostObject.Template = "Nodes.Add(`Root 1`)"
	var_NETHostObject1 = var_NETHostObject.TemplateResult
		var_NETHostObject1.Template = "Nodes.Add(`Child 1`)"
		var_NETHostObject1.Template = "Nodes.Add(`Child 2`)"
		var_NETHostObject1.Template = "Expand()"

XBasic (Alpha Five)

Dim oNETHost as P
Dim var_NETHostObject as P
Dim var_NETHostObject1 as P

oNETHost = topparent:CONTROL_ACTIVEX1.activex
oNETHost.AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
oNETHost.AssemblyName = "System.Windows.Forms.TreeView"
var_NETHostObject = oNETHost.Host
	var_NETHostObject.Template = "Nodes.Add(`Root 1`)"
	var_NETHostObject1 = var_NETHostObject.TemplateResult
		var_NETHostObject1.Template = "Nodes.Add(`Child 1`)"
		var_NETHostObject1.Template = "Nodes.Add(`Child 2`)"
		var_NETHostObject1.Template = "Expand()"

Visual Objects

local var_NETHostObject as INETHostObject
local var_NETHostObject1 as INETObjectTemplate

oDCOCX_Exontrol1:AssemblyLocation := "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
oDCOCX_Exontrol1:AssemblyName := "System.Windows.Forms.TreeView"
var_NETHostObject := oDCOCX_Exontrol1:Host
	var_NETHostObject:Template := "Nodes.Add(`Root 1`)"
	var_NETHostObject1 := var_NETHostObject:TemplateResult
		var_NETHostObject1:Template := "Nodes.Add(`Child 1`)"
		var_NETHostObject1:Template := "Nodes.Add(`Child 2`)"
		var_NETHostObject1:Template := "Expand()"

PowerBuilder

OleObject oNETHost,var_NETHostObject,var_NETHostObject1

oNETHost = ole_1.Object
oNETHost.AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
oNETHost.AssemblyName = "System.Windows.Forms.TreeView"
var_NETHostObject = oNETHost.Host
	var_NETHostObject.Template = "Nodes.Add(`Root 1`)"
	var_NETHostObject1 = var_NETHostObject.TemplateResult
		var_NETHostObject1.Template = "Nodes.Add(`Child 1`)"
		var_NETHostObject1.Template = "Nodes.Add(`Child 2`)"
		var_NETHostObject1.Template = "Expand()"

Visual DataFlex

Procedure OnCreate
	Forward Send OnCreate
	Set ComAssemblyLocation to "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
	Set ComAssemblyName to "System.Windows.Forms.TreeView"
	Variant voNETHostObject
	Get ComHost to voNETHostObject
	Handle hoNETHostObject
	Get Create (RefClass(cComNETHostObject)) to hoNETHostObject
	Set pvComObject of hoNETHostObject to voNETHostObject
		Set ComTemplate of hoNETHostObject to "Nodes.Add(`Root 1`)"
		Variant voNETHostObject1
		Get ComTemplateResult of hoNETHostObject to voNETHostObject1
		Handle hoNETHostObject1
		Get Create (RefClass(cComNETHostObject)) to hoNETHostObject1
		Set pvComObject of hoNETHostObject1 to voNETHostObject1
			Set ComTemplate of hoNETHostObject1 to "Nodes.Add(`Child 1`)"
			Set ComTemplate of hoNETHostObject1 to "Nodes.Add(`Child 2`)"
			Set ComTemplate of hoNETHostObject1 to "Expand()"
		Send Destroy to hoNETHostObject1
	Send Destroy to hoNETHostObject
End_Procedure

XBase++

#include "AppEvent.ch"
#include "ActiveX.ch"

PROCEDURE Main
 	LOCAL oForm
	LOCAL nEvent := 0, mp1 := NIL, mp2 := NIL, oXbp := NIL
	LOCAL oNETHostObject
	LOCAL oNETHostObject1
	LOCAL oNETHost

	oForm := XbpDialog():new( AppDesktop() )
	oForm:drawingArea:clipChildren := .T.
	oForm:create( ,,{100,100}, {640,480},, .F. )
	oForm:close  := {|| PostAppEvent( xbeP_Quit )}

	oNETHost := XbpActiveXControl():new( oForm:drawingArea )
	oNETHost:CLSID  := "Exontrol.NETHost" /*{FDCBA3E0-4E2F-4DC7-B073-EAA7BD7EC565}*/
	oNETHost:create(,, {10,60},{610,370} )

		oNETHost:AssemblyLocation := "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
		oNETHost:AssemblyName := "System.Windows.Forms.TreeView"
		oNETHostObject := oNETHost:Host()
			oNETHostObject:Template := "Nodes.Add(`Root 1`)"
			oNETHostObject1 := oNETHostObject:TemplateResult()
				oNETHostObject1:Template := "Nodes.Add(`Child 1`)"
				oNETHostObject1:Template := "Nodes.Add(`Child 2`)"
				oNETHostObject1:Template := "Expand()"

	oForm:Show()
	DO WHILE nEvent != xbeP_Quit
		nEvent := AppEvent( @mp1, @mp2, @oXbp )
		oXbp:handleEvent( nEvent, mp1, mp2 )
	ENDDO 
RETURN