event BeforeExpandItem (Item as HITEM, ByRef Cancel as Variant)

Fired before an item is about to be expanded (collapsed).

TypeDescription
Item as HITEM A long expression that indicates the handle of the item being expanded or collapsed.
Cancel as Variant (By Reference) A boolean expression that indicates whether the control cancel expanding or collapsing the item.

The BeforeExpandItem event notifies your application that an item is about to be collapsed or expanded. Use the BeforeExpandItem event to cancel expanding or collapsing items. Use the BeforeExpandItem event to load new items when filling a virtual tree. The AfterExpandItem event is fired after an item is expanded or collapsed.  Use the ExpandItem method to programmatically expand or collapse an item. Use the ExpandOnSearch property to expand items while user types characters to search for items using incremental search feature.

Syntax for BeforeExpandItem event, /NET version, on:

private void BeforeExpandItem(object sender,int Item,ref object Cancel)
{
}

Private Sub BeforeExpandItem(ByVal sender As System.Object,ByVal Item As Integer,ByRef Cancel As Object) Handles BeforeExpandItem
End Sub

Syntax for BeforeExpandItem event, /COM version, on:

private void BeforeExpandItem(object sender, AxEXGANTTLib._IGanttEvents_BeforeExpandItemEvent e)
{
}

void OnBeforeExpandItem(long Item,VARIANT FAR* Cancel)
{
}

void __fastcall BeforeExpandItem(TObject *Sender,Exganttlib_tlb::HITEM Item,Variant * Cancel)
{
}

procedure BeforeExpandItem(ASender: TObject; Item : HITEM;var Cancel : OleVariant);
begin
end;

procedure BeforeExpandItem(sender: System.Object; e: AxEXGANTTLib._IGanttEvents_BeforeExpandItemEvent);
begin
end;

begin event BeforeExpandItem(long Item,any Cancel)
end event BeforeExpandItem

Private Sub BeforeExpandItem(ByVal sender As System.Object, ByVal e As AxEXGANTTLib._IGanttEvents_BeforeExpandItemEvent) Handles BeforeExpandItem
End Sub

Private Sub BeforeExpandItem(ByVal Item As EXGANTTLibCtl.HITEM,Cancel As Variant)
End Sub

Private Sub BeforeExpandItem(ByVal Item As Long,Cancel As Variant)
End Sub

LPARAMETERS Item,Cancel

PROCEDURE OnBeforeExpandItem(oGantt,Item,Cancel)
RETURN

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

<SCRIPT EVENT="BeforeExpandItem(Item,Cancel)" LANGUAGE="JScript">
</SCRIPT>

<SCRIPT LANGUAGE="VBScript">
Function BeforeExpandItem(Item,Cancel)
End Function
</SCRIPT>

Procedure OnComBeforeExpandItem HITEM llItem Variant llCancel
	Forward Send OnComBeforeExpandItem llItem llCancel
End_Procedure

METHOD OCX_BeforeExpandItem(Item,Cancel) CLASS MainDialog
RETURN NIL

void onEvent_BeforeExpandItem(int _Item,COMVariant /*variant*/ _Cancel)
{
}

function BeforeExpandItem as v (Item as OLE::Exontrol.Gantt.1::HITEM,Cancel as A)
end function

function nativeObject_BeforeExpandItem(Item,Cancel)
return

The following VB sample cancels expanding or collapsing items:

Private Sub Gantt1_BeforeExpandItem(ByVal Item As EXGANTTLibCtl.HITEM, Cancel As Variant)
    Cancel = True
End Sub

The following VB sample prints the item's state when it is expanded or collapsed:

Private Sub Gantt1_AfterExpandItem(ByVal Item As EXGANTTLibCtl.HITEM)
    Debug.Print "The " & Item & " item was " & IIf(Gantt1.Items.ExpandItem(Item), "expanded", "collapsed")
End Sub

The following C# sample cancels expanding or collapsing items:

private void axGantt1_BeforeExpandItem(object sender, AxEXGANTTLib._IGanttEvents_BeforeExpandItemEvent e)
{
	e.cancel = true;
}

The following VB.NET sample cancels expanding or collapsing items:

Private Sub AxGantt1_BeforeExpandItem(ByVal sender As Object, ByVal e As AxEXGANTTLib._IGanttEvents_BeforeExpandItemEvent) Handles AxGantt1.BeforeExpandItem
    e.cancel = True
End Sub

The following C++ sample cancels expanding or collapsing items:

void OnBeforeExpandItemGantt1(long Item, VARIANT FAR* Cancel) 
{
	V_VT( Cancel ) = VT_BOOL;
	V_BOOL( Cancel ) = VARIANT_TRUE;
}

The following VFP sample cancels expanding or collapsing items:

*** ActiveX Control Event ***
LPARAMETERS item, cancel

cancel = .t.