![]() | Type | Description | ||
| 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.
The following VB sample disables expanding or collapsing items:
Private Sub Grid1_BeforeExpandItem(ByVal Item As EXGRIDLibCtl.HITEM, Cancel As Variant)
Cancel = True
End SubUse 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 SubThe 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 SubThe 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.