method NETObjectTemplate.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::INETObjectTemplatePtr var_NETObjectTemplate = spNETHost1->GetHost();
	var_NETObjectTemplate->SetTemplateDef("Dim x");
	var_NETObjectTemplate->SetTemplateDef(COleDateTime(2001,1,1,0,00,00).operator DATE());
	var_NETObjectTemplate->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::INETObjectTemplatePtr var_NETObjectTemplate = NETHost1->Host;
	var_NETObjectTemplate->SetTemplateDef(TVariant("Dim x"));
	var_NETObjectTemplate->SetTemplateDef(TVariant(TDateTime(2001,1,1).operator double()));
	var_NETObjectTemplate->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.NETObjectTemplate var_NETObjectTemplate = exnethost1.Host;
	var_NETObjectTemplate.SetTemplateDef("Dim x");
	var_NETObjectTemplate.SetTemplateDef(Convert.ToDateTime("1/1/2001",System.Globalization.CultureInfo.GetCultureInfo("en-US")));
	var_NETObjectTemplate.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_NETObjectTemplate = NETHost1.Host;
		var_NETObjectTemplate.SetTemplateDef("Dim x");
		var_NETObjectTemplate.SetTemplateDef("1/1/2001");
		var_NETObjectTemplate.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.NETObjectTemplate var_NETObjectTemplate = axNETHost1.Host;
	var_NETObjectTemplate.SetTemplateDef("Dim x");
	var_NETObjectTemplate.SetTemplateDef(Convert.ToDateTime("1/1/2001",System.Globalization.CultureInfo.GetCultureInfo("en-US")));
	var_NETObjectTemplate.Template = "MaxSelectionCount = 1;SelectionStart = x";

X++ (Dynamics Ax 2009)

public void init()
{
	COM com_NETObjectTemplate;
	anytype var_NETObjectTemplate;
	;

	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_NETObjectTemplate = exnethost1.Host(); com_NETObjectTemplate = var_NETObjectTemplate;
		com_NETObjectTemplate.SetTemplateDef("Dim x");
		com_NETObjectTemplate.SetTemplateDef(COMVariant::createFromDate(str2Date("1/1/2001",213)));
		com_NETObjectTemplate.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_NETObjectTemplate

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_NETObjectTemplate = oNETHost.Host
	var_NETObjectTemplate.SetTemplateDef("Dim x")
	var_NETObjectTemplate.SetTemplateDef("01/01/2001")
	var_NETObjectTemplate.Template = "MaxSelectionCount = 1;SelectionStart = x"

XBasic (Alpha Five)

Dim oNETHost as P
Dim var_NETObjectTemplate 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_NETObjectTemplate = oNETHost.Host
	var_NETObjectTemplate.SetTemplateDef("Dim x")
	var_NETObjectTemplate.SetTemplateDef({01/01/2001})
	var_NETObjectTemplate.Template = "MaxSelectionCount = 1;SelectionStart = x"

Visual Objects

local var_NETObjectTemplate as INETObjectTemplate

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_NETObjectTemplate := oDCOCX_Exontrol1:Host
	var_NETObjectTemplate:SetTemplateDef("Dim x")
	var_NETObjectTemplate:SetTemplateDef(SToD("20010101"))
	var_NETObjectTemplate:Template := "MaxSelectionCount = 1;SelectionStart = x"

PowerBuilder

OleObject oNETHost,var_NETObjectTemplate

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_NETObjectTemplate = oNETHost.Host
	var_NETObjectTemplate.SetTemplateDef("Dim x")
	var_NETObjectTemplate.SetTemplateDef(2001-01-01)
	var_NETObjectTemplate.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 voNETObjectTemplate
	Get ComHost to voNETObjectTemplate
	Handle hoNETObjectTemplate
	Get Create (RefClass(cComNETObjectTemplate)) to hoNETObjectTemplate
	Set pvComObject of hoNETObjectTemplate to voNETObjectTemplate
		Send ComSetTemplateDef of hoNETObjectTemplate "Dim x"
		Send ComSetTemplateDef of hoNETObjectTemplate "1/1/2001"
		Set ComTemplate of hoNETObjectTemplate to "MaxSelectionCount = 1;SelectionStart = x"
	Send Destroy to hoNETObjectTemplate
End_Procedure

XBase++

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

PROCEDURE Main
 	LOCAL oForm
	LOCAL nEvent := 0, mp1 := NIL, mp2 := NIL, oXbp := NIL
	LOCAL oNETObjectTemplate
	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")
		oNETObjectTemplate := oNETHost:Host()
			oNETObjectTemplate:SetTemplateDef("Dim x")
			oNETObjectTemplate:SetTemplateDef("01/01/2001")
			oNETObjectTemplate:Template := "MaxSelectionCount = 1;SelectionStart = x"

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