property Items.ItemHasChildren (Item as HITEM) as Boolean

Adds an expand button to left side of the item even if the item has no child items.

 TypeDescription 
   Item as HITEM A long expression that indicates the handle of the item.  
   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 combobox. 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 ComboBox1_BeforeExpandItem(ByVal Item As EXCOMBOBOXLibCtl.HITEM, Cancel As Variant)
    With ComboBox1.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 AxComboBox1_BeforeExpandItem(ByVal sender As Object, ByVal e As AxEXCOMBOBOXLib._IComboBoxEvents_BeforeExpandItemEvent) Handles AxComboBox1.BeforeExpandItem
    With AxComboBox1.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 axComboBox1_BeforeExpandItem(object sender, AxEXCOMBOBOXLib._IComboBoxEvents_BeforeExpandItemEvent e)
{
	EXCOMBOBOXLib.Items items = axComboBox1.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 OnBeforeExpandItemComboBox1(long Item, VARIANT FAR* Cancel) 
{
	CItems items = m_combobox.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.ComboBox1.Items
	if ( .ItemHasChildren( item ) )
		if ( .ChildCount( item ) = 0 )
			.InsertItem(item,"","new " + trim(str(item)))
		endif
	endif	
endwith

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