event BeforeExpandItem (Item as HITEM, Cancel as Variant)
Fired before an item is about to be expanded (collapsed).

 TypeDescription 
   Item as HITEM A long expression that indicates the item being expanded or collapsed.   
   Cancel as Variant A boolean expression that indicates whether the expanding or collapsing operation is canceled.  

Use the AfterExpandItem and BeforeExpandItem events to notify your application that an item is expanded or collapsed. Use the ExpandItem property to expand or collapse items at runtime. Use the BeforeExpandItem event to disable expanding or collapsing the items. Use the ItemHasChildren property to specify whether the control should display a + sign to the items, even they have no child items, so you can build a virtual tree. A virtual tree can load items as soon as user expands an item. Use the ExpandOnSearch property to expand items while user types characters to search for items using incremental search feature. Use the ChildCount property to get the number of child items. Use the ItemChild property to retrieve the first child item.

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, AxEXGRIDLib._IGridEvents_BeforeExpandItemEvent e)
{
}

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

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

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

procedure BeforeExpandItem(sender: System.Object; e: AxEXGRIDLib._IGridEvents_BeforeExpandItemEvent);
begin
end;

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

Private Sub BeforeExpandItem(ByVal sender As System.Object, ByVal e As AxEXGRIDLib._IGridEvents_BeforeExpandItemEvent) Handles BeforeExpandItem
End Sub

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

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

LPARAMETERS Item,Cancel

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

function nativeObject_BeforeExpandItem(Item,Cancel)
return

The following VB sample disables expanding or collapsing items:

Private Sub Grid1_BeforeExpandItem(ByVal Item As EXGRIDLibCtl.HITEM, Cancel As Variant)
    Cancel = True
End Sub

Use the BeforeExpandItem event to add child items when an item is expanded, and has the ItemHasChildren property on True, like in the following VB sample:

Private Sub Grid1_BeforeExpandItem(ByVal Item As EXGRIDLibCtl.HITEM, Cancel As Variant)
    With Grid1.Items
        If (.ItemHasChildren(Item)) Then
            If (.ChildCount(Item) = 0) Then
                .InsertItem Item, , "new item " & Item
            End If
        End If
    End With
End Sub

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

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

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

Private Sub AxGrid1_BeforeExpandItem(ByVal sender As Object, ByVal e As AxEXGRIDLib._IGridEvents_BeforeExpandItemEvent) Handles AxGrid1.BeforeExpandItem
    e.cancel = True
End Sub

The following C# sample cancels expanding or collapsing items:

private void axGrid1_BeforeExpandItem(object sender, AxEXGRIDLib._IGridEvents_BeforeExpandItemEvent e)
{
	e.cancel = true;
}

The following VFP sample cancels expanding or collapsing items:

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

cancel = .t.

 


Send comments on this topic.
1999-2017 Exontrol.COM, Software. All rights reserved.