Adds an expand button to left side of the item even if the item has no child items.
Type | Description | |||
Item as HITEM | A long expression that indicates the item's handle. | |||
Boolean | A boolean expression that indicates whether the control adds an expand button to the left side of the item even if the item has no child items. |
By default, the ItemHasChidren property is False. Use the ItemHasChildren property to build a virtual tree. Use the BeforeExpandItem event to add new child items to the expanded item. Use the ItemChild property to get the first child item, if exists. Use the ItemChild or ChildCount property to determine whether an item contains child items. The control displays a +/- sign to parent items, if the HasButtons property is not empty, the ItemChild property is not empty, or the ItemHasChildren property is True. Use the InsertItem method to insert a new child item. Use the CellData or ItemData property to assign an extra value to a cell or to an item.
The following VB sample inserts a child item as soon as user expands an item ( the sample has effect only if your control contains items that have the ItemHasChildren property on True ):
Private Sub G2antt1_BeforeExpandItem(ByVal Item As EXG2ANTTLibCtl.HITEM, Cancel As Variant) With G2antt1.Items If (.ItemHasChildren(Item)) Then If .ChildCount(Item) = 0 Then Dim h As Long h = .InsertItem(Item, , "new " & Item) End If End If End With End Sub
The following VB.NET sample inserts a child item when the user expands an item that has the ItemHasChildren property on True:
Private Sub AxG2antt1_BeforeExpandItem(ByVal sender As Object, ByVal e As AxEXG2ANTTLib._IG2anttEvents_BeforeExpandItemEvent) Handles AxG2antt1.BeforeExpandItem With AxG2antt1.Items If (.ItemHasChildren(e.item)) Then If .ChildCount(e.item) = 0 Then Dim h As Long h = .InsertItem(e.item, , "new " & e.item.ToString()) End If End If End With End Sub
The following C# sample inserts a child item when the user expands an item that has the ItemHasChildren property on True:
private void axG2antt1_BeforeExpandItem(object sender, AxEXG2ANTTLib._IG2anttEvents_BeforeExpandItemEvent e) { EXG2ANTTLib.Items items = axG2antt1.Items; if ( items.get_ItemHasChildren( e.item ) ) if (items.get_ChildCount(e.item) == 0) { items.InsertItem(e.item, null, "new " + e.item.ToString()); } }
The following C++ sample inserts a child item when the user expands an item that has the ItemHasChildren property on True:
#include "Items.h" void OnBeforeExpandItemG2antt1(long Item, VARIANT FAR* Cancel) { CItems items = m_g2antt.GetItems(); if ( items.GetItemHasChildren( Item ) ) if ( items.GetChildCount( Item ) == 0 ) { COleVariant vtMissing; V_VT( &vtMissing ) = VT_ERROR; items.InsertItem( Item, vtMissing, COleVariant( "new item" ) ); } }
The following VFP sample inserts a child item when the user expands an item that has the ItemHasChildren property on True( BeforeExpandItem event ):
*** ActiveX Control Event *** LPARAMETERS item, cancel with thisform.G2antt1.Items if ( .ItemHasChildren( item ) ) if ( .ChildCount( item ) = 0 ) .InsertItem(item,"","new " + trim(str(item))) endif endif endwith