method NETHostObject.SetTemplateDef (Value as Variant)
Defines inside variables for the next Template/ExecuteTemplate call.

TypeDescription
Value as Variant If calling the first time, A String expression that indicates the DIM command to define the variables that follows, or a VARIANT expression that defines the value of the variable in the order as they were defined. 
The SetTemplateDef method was provided to let you use values/objects inside the next Template/Item call. For instance, let's say you have a date field in your form, and once the user fills it, you want a /NET Frameworks MonthCalendar object to select it. In order to do that you have to call a code like:
With NETHost1
	.BackgroundColor = 16777215
	.Create "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll","System.Windows.Forms.MonthCalendar"
	With .Host
		.SetTemplateDef "Dim x"
		.SetTemplateDef #1/1/2001#
		.Template = "MaxSelectionCount = 1;SelectionStart = x"
	End With
End With

This sample defines the variable x  to be 1/1/2001 for the Template call, so the SelectionStart will be set on 1/1/2001.

The call of SetTemplateDef method consists in:

Once you defined the variables, they will be available for the next calls of Template/Item properties.

The following samples shows how you can define the x variable to be set on the SelectionStart property of the MonthCalendar object: 

VBA (MS Access, Excell...)

With NETHost1
	.BackgroundColor = 16777215
	.Create "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll","System.Windows.Forms.MonthCalendar"
	With .Host
		.SetTemplateDef "Dim x"
		.SetTemplateDef #1/1/2001#
		.Template = "MaxSelectionCount = 1;SelectionStart = x"
	End With
End With

VB6

With NETHost1
	.BackgroundColor = 16777215
	.Create "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll","System.Windows.Forms.MonthCalendar"
	With .Host
		.SetTemplateDef "Dim x"
		.SetTemplateDef #1/1/2001#
		.Template = "MaxSelectionCount = 1;SelectionStart = x"
	End With
End With

VB.NET

With Exnethost1
	.BackgroundColor = 16777215
	.Create("C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll","System.Windows.Forms.MonthCalendar")
	With .Host
		.SetTemplateDef("Dim x")
		.SetTemplateDef(#1/1/2001#)
		.Template = "MaxSelectionCount = 1;SelectionStart = x"
	End With
End With

VB.NET for /COM

With AxNETHost1
	.BackgroundColor = 16777215
	.Create("C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll","System.Windows.Forms.MonthCalendar")
	With .Host
		.SetTemplateDef("Dim x")
		.SetTemplateDef(#1/1/2001#)
		.Template = "MaxSelectionCount = 1;SelectionStart = x"
	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->PutBackgroundColor(16777215);
spNETHost1->Create(L"C:\\Windows\\assembly\\GAC_MSIL\\System.Windows.Forms\\2.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll",L"System.Windows.Forms.MonthCalendar");
exontrol_NETHost::INETHostObjectPtr var_NETHostObject = spNETHost1->GetHost();
	var_NETHostObject->SetTemplateDef("Dim x");
	var_NETHostObject->SetTemplateDef(COleDateTime(2001,1,1,0,00,00).operator DATE());
	var_NETHostObject->PutTemplate(L"MaxSelectionCount = 1;SelectionStart = x");

C++ Builder

NETHost1->BackgroundColor = 16777215;
NETHost1->Create(L"C:\\Windows\\assembly\\GAC_MSIL\\System.Windows.Forms\\2.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll",L"System.Windows.Forms.MonthCalendar");
Exontrol_nethost_tlb::INETHostObjectPtr var_NETHostObject = NETHost1->Host;
	var_NETHostObject->SetTemplateDef(TVariant("Dim x"));
	var_NETHostObject->SetTemplateDef(TVariant(TDateTime(2001,1,1).operator double()));
	var_NETHostObject->Template = L"MaxSelectionCount = 1;SelectionStart = x";

C#

exnethost1.BackgroundColor = 16777215;
exnethost1.Create("C:\\Windows\\assembly\\GAC_MSIL\\System.Windows.Forms\\2.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll","System.Windows.Forms.MonthCalendar");
exontrol_NETHost.NETHostObject var_NETHostObject = exnethost1.Host;
	var_NETHostObject.SetTemplateDef("Dim x");
	var_NETHostObject.SetTemplateDef(Convert.ToDateTime("1/1/2001",System.Globalization.CultureInfo.GetCultureInfo("en-US")));
	var_NETHostObject.Template = "MaxSelectionCount = 1;SelectionStart = x";

JScript/JavaScript

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

<SCRIPT LANGUAGE="JScript">
function Init()
{
	NETHost1.BackgroundColor = 16777215;
	NETHost1.Create("C:\\Windows\\assembly\\GAC_MSIL\\System.Windows.Forms\\2.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll","System.Windows.Forms.MonthCalendar");
	var var_NETHostObject = NETHost1.Host;
		var_NETHostObject.SetTemplateDef("Dim x");
		var_NETHostObject.SetTemplateDef("1/1/2001");
		var_NETHostObject.Template = "MaxSelectionCount = 1;SelectionStart = x";
}
</SCRIPT>
</BODY>

VBScript

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

<SCRIPT LANGUAGE="VBScript">
Function Init()
	With NETHost1
		.BackgroundColor = 16777215
		.Create "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll","System.Windows.Forms.MonthCalendar"
		With .Host
			.SetTemplateDef "Dim x"
			.SetTemplateDef #1/1/2001#
			.Template = "MaxSelectionCount = 1;SelectionStart = x"
		End With
	End With
End Function
</SCRIPT>
</BODY>

C# for /COM

axNETHost1.BackgroundColor = 16777215;
axNETHost1.Create("C:\\Windows\\assembly\\GAC_MSIL\\System.Windows.Forms\\2.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll","System.Windows.Forms.MonthCalendar");
exontrol_NETHost.NETHostObject var_NETHostObject = axNETHost1.Host;
	var_NETHostObject.SetTemplateDef("Dim x");
	var_NETHostObject.SetTemplateDef(Convert.ToDateTime("1/1/2001",System.Globalization.CultureInfo.GetCultureInfo("en-US")));
	var_NETHostObject.Template = "MaxSelectionCount = 1;SelectionStart = x";

X++ (Dynamics Ax 2009)

public void init()
{
	COM com_NETHostObject;
	anytype var_NETHostObject;
	;

	super();

	exnethost1.BackgroundColor(16777215);
	exnethost1.Create("C:\\Windows\\assembly\\GAC_MSIL\\System.Windows.Forms\\2.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll","System.Windows.Forms.MonthCalendar");
	var_NETHostObject = exnethost1.Host(); com_NETHostObject = var_NETHostObject;
		com_NETHostObject.SetTemplateDef("Dim x");
		com_NETHostObject.SetTemplateDef(COMVariant::createFromDate(str2Date("1/1/2001",213)));
		com_NETHostObject.Template("MaxSelectionCount = 1;SelectionStart = x");
}

Delphi 8 (.NET only)

with AxNETHost1 do
begin
	BackgroundColor := 16777215;
	Create('C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll','System.Windows.Forms.MonthCalendar');
	with Host do
	begin
		SetTemplateDef('Dim x');
		SetTemplateDef('1/1/2001');
		Template := 'MaxSelectionCount = 1;SelectionStart = x';
	end;
end

Delphi (standard)

with NETHost1 do
begin
	BackgroundColor := 16777215;
	Create('C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll','System.Windows.Forms.MonthCalendar');
	with Host do
	begin
		SetTemplateDef('Dim x');
		SetTemplateDef('1/1/2001');
		Template := 'MaxSelectionCount = 1;SelectionStart = x';
	end;
end

VFP

with thisform.NETHost1
	.BackgroundColor = 16777215
	.Create("C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll","System.Windows.Forms.MonthCalendar")
	with .Host
		.SetTemplateDef("Dim x")
		.SetTemplateDef({^2001-1-1})
		.Template = "MaxSelectionCount = 1;SelectionStart = x"
	endwith
endwith

dBASE Plus

local oNETHost,var_NETHostObject

oNETHost = form.Activex1.nativeObject
oNETHost.BackgroundColor = 16777215
oNETHost.Create("C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll","System.Windows.Forms.MonthCalendar")
var_NETHostObject = oNETHost.Host
	var_NETHostObject.SetTemplateDef("Dim x")
	var_NETHostObject.SetTemplateDef("01/01/2001")
	var_NETHostObject.Template = "MaxSelectionCount = 1;SelectionStart = x"

XBasic (Alpha Five)

Dim oNETHost as P
Dim var_NETHostObject as P

oNETHost = topparent:CONTROL_ACTIVEX1.activex
oNETHost.BackgroundColor = 16777215
oNETHost.Create("C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll","System.Windows.Forms.MonthCalendar")
var_NETHostObject = oNETHost.Host
	var_NETHostObject.SetTemplateDef("Dim x")
	var_NETHostObject.SetTemplateDef({01/01/2001})
	var_NETHostObject.Template = "MaxSelectionCount = 1;SelectionStart = x"

Visual Objects

local var_NETHostObject as INETHostObject

oDCOCX_Exontrol1:BackgroundColor := 16777215
oDCOCX_Exontrol1:Create("C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll","System.Windows.Forms.MonthCalendar")
var_NETHostObject := oDCOCX_Exontrol1:Host
	var_NETHostObject:SetTemplateDef("Dim x")
	var_NETHostObject:SetTemplateDef(SToD("20010101"))
	var_NETHostObject:Template := "MaxSelectionCount = 1;SelectionStart = x"

PowerBuilder

OleObject oNETHost,var_NETHostObject

oNETHost = ole_1.Object
oNETHost.BackgroundColor = 16777215
oNETHost.Create("C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll","System.Windows.Forms.MonthCalendar")
var_NETHostObject = oNETHost.Host
	var_NETHostObject.SetTemplateDef("Dim x")
	var_NETHostObject.SetTemplateDef(2001-01-01)
	var_NETHostObject.Template = "MaxSelectionCount = 1;SelectionStart = x"

Visual DataFlex

Procedure OnCreate
	Forward Send OnCreate
	Set ComBackgroundColor to 16777215
	Get ComCreate "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll" "System.Windows.Forms.MonthCalendar" to Nothing
	Variant voNETHostObject
	Get ComHost to voNETHostObject
	Handle hoNETHostObject
	Get Create (RefClass(cComNETHostObject)) to hoNETHostObject
	Set pvComObject of hoNETHostObject to voNETHostObject
		Send ComSetTemplateDef of hoNETHostObject "Dim x"
		Send ComSetTemplateDef of hoNETHostObject "1/1/2001"
		Set ComTemplate of hoNETHostObject to "MaxSelectionCount = 1;SelectionStart = x"
	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 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:BackgroundColor := 16777215
		oNETHost:Create("C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll","System.Windows.Forms.MonthCalendar")
		oNETHostObject := oNETHost:Host()
			oNETHostObject:SetTemplateDef("Dim x")
			oNETHostObject:SetTemplateDef("01/01/2001")
			oNETHostObject:Template := "MaxSelectionCount = 1;SelectionStart = x"

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