method Elements.Add ([Caption as Variant], [X as Variant], [Y as Variant])
Adds an Element object to the collection and returns a reference to the newly created object.

TypeDescription
Caption as Variant A String expression that specifies the caption to be displayed on the element. The Caption property specifies the value of the Caption parameter. Use the CaptionAlign property to align the element's caption.
X as Variant A long expression that specifies the x-position where the element is sown. If missing, the element is shown at (0,0) position on the surface. The X property indicates the element's x-position on the surface.
Y as Variant A long expression that specifies the y-position where the element is sown. If missing, the element is shown at (0,0) position on the surface. The X property indicates the element's x-position on the surface.
ReturnDescription
ElementAn Element object that represents the newly created and added element.
The Add method adds programmatically a new element to the surface. Use the InsertControl method to insert programmatically a child element that hosts an inner ActiveX control. The control fires the AddElement event once a new element is added to the Elements collection. The AutoSize property specifies whether the element's size if computed automatically based on its content. While the AutoSize property is True, the element is not resizable. Use the Width / Height property to specify the size of the element. The AllowCreateElement property specifies the combination of keys that allows the user to create objects on the surface. The Copy property copies the element. The  Arrange( ID ) method arranges the elements starting from element with the specified ID. If missing, all linked-elements are arranged.

The following samples show how you can programmatically add a new element:

VBA (MS Access, Excell...)

With SwimLane1
	With .Elements
		.Add "new 1"
		.Add "new 1",24,24
	End With
End With

VB6

With SwimLane1
	With .Elements
		.Add "new 1"
		.Add "new 1",24,24
	End With
End With

VB.NET

With Exswimlane1
	With .Elements
		.Add("new 1")
		.Add("new 1",24,24)
	End With
End With

VB.NET for /COM

With AxSwimLane1
	With .Elements
		.Add("new 1")
		.Add("new 1",24,24)
	End With
End With

C++

/*
	Copy and paste the following directives to your header file as
	it defines the namespace 'EXSWIMLANELib' for the library: 'ExSwimLane 1.0 Control Library'

	#import <ExSwimLane.dll>
	using namespace EXSWIMLANELib;
*/
EXSWIMLANELib::ISwimLanePtr spSwimLane1 = GetDlgItem(IDC_SWIMLANE1)->GetControlUnknown();
EXSWIMLANELib::IElementsPtr var_Elements = spSwimLane1->GetElements();
	var_Elements->Add("new 1",vtMissing,vtMissing);
	var_Elements->Add("new 1",long(24),long(24));

C++ Builder

Exswimlanelib_tlb::IElementsPtr var_Elements = SwimLane1->Elements;
	var_Elements->Add(TVariant("new 1"),TNoParam(),TNoParam());
	var_Elements->Add(TVariant("new 1"),TVariant(24),TVariant(24));

C#

exontrol.EXSWIMLANELib.Elements var_Elements = exswimlane1.Elements;
	var_Elements.Add("new 1",null,null);
	var_Elements.Add("new 1",24,24);

JavaScript

<OBJECT classid="clsid:AFA73FCE-6609-4062-AE6A-4BAD6D96A025" id="SwimLane1"></OBJECT>

<SCRIPT LANGUAGE="JScript">
	var var_Elements = SwimLane1.Elements;
		var_Elements.Add("new 1",null,null);
		var_Elements.Add("new 1",24,24);
</SCRIPT>

C# for /COM

EXSWIMLANELib.Elements var_Elements = axSwimLane1.Elements;
	var_Elements.Add("new 1",null,null);
	var_Elements.Add("new 1",24,24);

X++ (Dynamics Ax 2009)

public void init()
{
	COM com_Elements;
	anytype var_Elements;
	;

	super();

	var_Elements = exswimlane1.Elements(); com_Elements = var_Elements;
		com_Elements.Add("new 1");
		com_Elements.Add("new 1",COMVariant::createFromInt(24),COMVariant::createFromInt(24));
}

Delphi 8 (.NET only)

with AxSwimLane1 do
begin
	with Elements do
	begin
		Add('new 1',Nil,Nil);
		Add('new 1',TObject(24),TObject(24));
	end;
end

Delphi (standard)

with SwimLane1 do
begin
	with Elements do
	begin
		Add('new 1',Null,Null);
		Add('new 1',OleVariant(24),OleVariant(24));
	end;
end

VFP

with thisform.SwimLane1
	with .Elements
		.Add("new 1")
		.Add("new 1",24,24)
	endwith
endwith

dBASE Plus

local oSwimLane,var_Elements

oSwimLane = form.Activex1.nativeObject
var_Elements = oSwimLane.Elements
	var_Elements.Add("new 1")
	var_Elements.Add("new 1",24,24)

XBasic (Alpha Five)

Dim oSwimLane as P
Dim var_Elements as P

oSwimLane = topparent:CONTROL_ACTIVEX1.activex
var_Elements = oSwimLane.Elements
	var_Elements.Add("new 1")
	var_Elements.Add("new 1",24,24)

Visual Objects

local var_Elements as IElements

var_Elements := oDCOCX_Exontrol1:Elements
	var_Elements:Add("new 1",nil,nil)
	var_Elements:Add("new 1",24,24)

PowerBuilder

OleObject oSwimLane,var_Elements

oSwimLane = ole_1.Object
var_Elements = oSwimLane.Elements
	var_Elements.Add("new 1")
	var_Elements.Add("new 1",24,24)

Visual DataFlex

Procedure OnCreate
	Forward Send OnCreate
	Variant voElements
	Get ComElements to voElements
	Handle hoElements
	Get Create (RefClass(cComElements)) to hoElements
	Set pvComObject of hoElements to voElements
		Get ComAdd of hoElements "new 1" Nothing Nothing to Nothing
		Get ComAdd of hoElements "new 1" 24 24 to Nothing
	Send Destroy to hoElements
End_Procedure

XBase++

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

PROCEDURE Main
 	LOCAL oForm
	LOCAL nEvent := 0, mp1 := NIL, mp2 := NIL, oXbp := NIL
	LOCAL oElements
	LOCAL oSwimLane

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

	oSwimLane := XbpActiveXControl():new( oForm:drawingArea )
	oSwimLane:CLSID  := "Exontrol.SwimLane.1" /*{AFA73FCE-6609-4062-AE6A-4BAD6D96A025}*/
	oSwimLane:create(,, {10,60},{610,370} )

		oElements := oSwimLane:Elements()
			oElements:Add("new 1")
			oElements:Add("new 1",24,24)

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