event CreateElement (Element as Element)
The user creates at runtime a new element.

TypeDescription
Element as Element An Element object being created.
The CreateElement event occurs when the user creates the element on the surface. The AllowCreateObject property specifies the keys combination to let the user creates the elements at runtime. Prior to CreateElement event the AddElement event is fired to notify that the element has been added to the Elements collection. The CreateElement event is not fired when you add programmatically the element calling the Add method. For instance, you can call the Element.Edit method during the CreateElement to let the user edits the element's caption once a new element is created. You can call the Remove method to remove the newly created element.

The order of the events when the user creates the element at runtime is:

The CreateElement event is not called during the LoadXML method.

Syntax for CreateElement event, /NET version, on:

private void CreateElement(object sender,exontrol.EXSURFACELib.Element Element)
{
}

Private Sub CreateElement(ByVal sender As System.Object,ByVal Element As exontrol.EXSURFACELib.Element) Handles CreateElement
End Sub

Syntax for CreateElement event, /COM version, on:

private void CreateElement(object sender, AxEXSURFACELib._ISurfaceEvents_CreateElementEvent e)
{
}

void OnCreateElement(LPDISPATCH Element)
{
}

void __fastcall CreateElement(TObject *Sender,Exsurfacelib_tlb::IElement *Element)
{
}

procedure CreateElement(ASender: TObject; Element : IElement);
begin
end;

procedure CreateElement(sender: System.Object; e: AxEXSURFACELib._ISurfaceEvents_CreateElementEvent);
begin
end;

begin event CreateElement(oleobject Element)
end event CreateElement

Private Sub CreateElement(ByVal sender As System.Object, ByVal e As AxEXSURFACELib._ISurfaceEvents_CreateElementEvent) Handles CreateElement
End Sub

Private Sub CreateElement(ByVal Element As EXSURFACELibCtl.IElement)
End Sub

Private Sub CreateElement(ByVal Element As Object)
End Sub

LPARAMETERS Element

PROCEDURE OnCreateElement(oSurface,Element)
RETURN

Syntax for CreateElement event, /COM version (others), on:

<SCRIPT EVENT="CreateElement(Element)" LANGUAGE="JScript">
</SCRIPT>

<SCRIPT LANGUAGE="VBScript">
Function CreateElement(Element)
End Function
</SCRIPT>

Procedure OnComCreateElement Variant llElement
	Forward Send OnComCreateElement llElement
End_Procedure

METHOD OCX_CreateElement(Element) CLASS MainDialog
RETURN NIL

void onEvent_CreateElement(COM _Element)
{
}

function CreateElement as v (Element as OLE::Exontrol.Surface.1::IElement)
end function

function nativeObject_CreateElement(Element)
return

The following VB sample calls the Edit method once a new element is created:

Private Sub Surface1_CreateElement(ByVal Element As EXSURFACELibCtl.IElement)
    With Element
        .AutoSize = True
        .Caption = "new " & Surface1.Elements.Count
        .Edit exEditCaption
    End With
End Sub

The following VB sample creates an element that hosts the Exontrol.Button control:

Private Sub Surface1_CreateElement(ByVal Element As EXSURFACELibCtl.IElement)
    With Element
        .Type = exElementHostControl
        .ElementFormat = """client"""
        .Control = "Exontrol.Button"
        With .Object
            .Caption = "<sha ;;0>Button " & Surface1.Elements.Count
        End With
    End With
End Sub