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 user cancels the expanding/collapsing operation.

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.

The following VB sample cancels expanding or collapsing items:

Private Sub ComboBox1_BeforeExpandItem(ByVal Item As EXCOMBOBOXLibCtl.HITEM, Cancel As Variant)
    Cancel = True
End Sub

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

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

The following C# sample cancels expanding or collapsing items:

private void axComboBox1_BeforeExpandItem(object sender, AxEXCOMBOBOXLib._IComboBoxEvents_BeforeExpandItemEvent e)
{
	e.cancel = true;
}

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

Private Sub AxComboBox1_BeforeExpandItem(ByVal sender As Object, ByVal e As AxEXCOMBOBOXLib._IComboBoxEvents_BeforeExpandItemEvent) Handles AxComboBox1.BeforeExpandItem
    e.cancel = True
End Sub

The following VFP sample cancels expanding or collapsing items:

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

cancel = .t.


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, AxEXCOMBOBOXLib._IComboBoxEvents_BeforeExpandItemEvent e)
{
}

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

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

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

procedure BeforeExpandItem(sender: System.Object; e: AxEXCOMBOBOXLib._IComboBoxEvents_BeforeExpandItemEvent);
begin
end;

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

Private Sub BeforeExpandItem(ByVal sender As System.Object, ByVal e As AxEXCOMBOBOXLib._IComboBoxEvents_BeforeExpandItemEvent) Handles BeforeExpandItem
End Sub

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

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

LPARAMETERS Item,Cancel

PROCEDURE OnBeforeExpandItem(oComboBox,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.ComboBox.1::HITEM,Cancel as A)
end function

function nativeObject_BeforeExpandItem(Item,Cancel)
return