event HostEvent (EventID as HostEventEnum)
Notifies the application once the host fires an event.

TypeDescription
EventID as HostEventEnum A Long expression that defines the identifier of the event that occurs. 

The EventID parameter can be:

  • positive, to indicate that the control did not handle yet the event (before)
  • negative, to indicate that the control handled the event (after)
The HostEvent(EventID) event occurs once the host-control (exg2antt) fires an event and before the control itself to handle the event. The HostEvent(-EventID) event (negative event) occurs once the host-control (exg2antt) fires an event and after the control itself handles the event (starting from version 19.0). Each event has different number of parameters, which is indicated by the HostEventParam(-1) property. Each parameter of the event can be accessed through the HostEventParam property. The HostEventParam(-2) gives a general information of the event. 

The HostEvent event occurs once the host-control (exg2antt) fires an event. The HostEvent(EventID) event (positive-event) is fired before the control itself to handle the event, while HostEvent(-EventID) event (negative-event) is fired after the control itself handles the event. For instance, HostEvent(exHostCreateBar) event notifies your application that a new bar is about to be created by drag and drop (the bar is not yet created), while HostEvent(-exHostCreateBar) event occurs once the control created the newly bar. During the HostEvent(-exHostCreateBar) event you can access the newly created bar using the HostEventParam(0) that returns the handle of the item that hosts the item-bar, and HostDef(exNewTaskID) gets the key of the newly created bar.

The following VB sample displays information about the host's events:

Private Sub G2Host1_HostEvent(ByVal EventID As EXG2HOSTLibCtl.HostEventEnum)
    Debug.Print G2Host1.HostEventParam(-2)
End Sub

The following VB sample changes the color for the newly created bar:

Private Sub G2Host1_HostEvent(ByVal EventID As EXG2HOSTLibCtl.HostEventEnum)
    If (EventID = -exHostCreateBar) Then
        G2Host1.Host.Items.ItemBar(G2Host1.HostEventParam(0), G2Host1.HostDef(exNewTaskID), 33) = RGB(255, 0, 0)
    End If
End Sub

The following VB sample displays a message box, before pressing the Delete key, and cancel the operation if user selects No or Cancel:

Private Sub G2Host1_HostEvent(ByVal EventID As EXG2HOSTLibCtl.HostEventEnum)
    If (EventID = exHostKeyDown) Then
        If (vbKeyDelete = CInt(G2Host1.HostEventParam(0))) Then
            If Not (MsgBox("Do you want to delete?", vbYesNoCancel) = vbYes) Then
                G2Host1.HostEventParam(0) = 0
            End If
        End If
    End If
End Sub
You can disable completely deletion by removing the exHostAllowDelete flag from the HostReadOnly property.

Syntax for HostEvent event, /NET version, on:

private void HostEvent(object sender,exontrol.EXG2HOSTLib.HostEventEnum   EventID)
{
}

Private Sub HostEvent(ByVal sender As System.Object,ByVal EventID As exontrol.EXG2HOSTLib.HostEventEnum) Handles HostEvent
End Sub

Syntax for HostEvent event, /COM version, on:

private void HostEvent(object sender, AxEXG2HOSTLib._IG2HostEvents_HostEventEvent e)
{
}

void OnHostEvent(long   EventID)
{
}

void __fastcall HostEvent(TObject *Sender,Exg2hostlib_tlb::HostEventEnum   EventID)
{
}

procedure HostEvent(ASender: TObject; EventID : HostEventEnum);
begin
end;

procedure HostEvent(sender: System.Object; e: AxEXG2HOSTLib._IG2HostEvents_HostEventEvent);
begin
end;

begin event HostEvent(long  EventID)

end event HostEvent

Private Sub HostEvent(ByVal sender As System.Object, ByVal e As AxEXG2HOSTLib._IG2HostEvents_HostEventEvent) Handles HostEvent
End Sub

Private Sub HostEvent(ByVal EventID As EXG2HOSTLibCtl.HostEventEnum)
End Sub

Private Sub HostEvent(ByVal EventID As Long)
End Sub

LPARAMETERS EventID

PROCEDURE OnHostEvent(oG2Host,EventID)

RETURN

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

<SCRIPT EVENT="HostEvent(EventID)" LANGUAGE="JScript">
</SCRIPT>

<SCRIPT LANGUAGE="VBScript">
Function HostEvent(EventID)
End Function
</SCRIPT>

Procedure OnComHostEvent OLEHostEventEnum   llEventID
	Forward Send OnComHostEvent llEventID
End_Procedure

METHOD OCX_HostEvent(EventID) CLASS MainDialog
RETURN NIL

void onEvent_HostEvent(int   _EventID)
{
}

function HostEvent as v (EventID  as  OLE::Exontrol.G2Host.1::HostEventEnum)
end function

function nativeObject_HostEvent(EventID)
return