property Items.ExpandItem(Item as HITEM) as Boolean

Expands, or collapses, the child items of the specified item.

TypeDescription
Item as HITEM A long expression that indicates the item's handle. If the Item is 0, setting the ExpandItem property expands or collapses all items. For instance, the ExpandItem(0) = False, collapses all items, while the ExpandItem(0) = True, expands all items.
Boolean A boolean expression that indicates whether the item is expanded or collapsed.

Use ExpandItem property to programmatically expand or collapse an item. Use the ExpandItem property to check whether an item is expanded or collapsed. Before expanding/collapsing an item, the control fires the BeforeExpandItem event. Use the BeforeExpandItem event to cancel expanding/collapsing of an item. After item is expanded/collapsed the control fires the AfterExpandItem event. The following samples shows how to expand the selected item: ComboBox1.Items.ExpandItem(ComboBox1.Items.SelectedItem()) = True. The property has no effect if the item has no child items. To check if the item has child items you can use ChildCount property. Use the ItemHasChildren property to display a +/- expand sign to the item even if it doesn't contain child items. The ExpandOnSearch property specifies whether the control expands nodes when incremental searching is on ( AutoSearch property is different than 0 ) and user types characters when the control has the focus. Use the InsertItem property to add child items.

The following VB sample programmatically expands the item when the user selects it :

Private Sub ComboBox1_SelectionChanged()
    ComboBox1.Items.ExpandItem(ComboBox1.Items.SelectedItem()) = True
End Sub

The following VB sample expands programmatically the focused item:

With ComboBox1.Items
    .ExpandItem(.FocusItem) = True
End With

The following C++ sample expands programmatically the focused item:

#include "Items.h"
CItems items = m_combobox.GetItems();
items.SetExpandItem( items.GetFocusItem(), TRUE );

The following VB.NET sample expands programmatically the focused item:

AxComboBox1.Items.ExpandItem( AxComboBox1.Items.FocusItem ) = True

The following C# sample expands programmatically the focused item:

axComboBox1.Items.set_ExpandItem( axComboBox1.Items.FocusItem, true );

The following VFP sample expands programmatically the focused item:

with thisform.ComboBox1.Items
	.DefaultItem = .FocusItem
	.ExpandItem( 0 ) = .t.
endwith