Expands, or collapses, the child items of the specified item.
|Item as HITEM||A long expression that indicates the handle of the item being expanded or collapsed. 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 items is expanded or collapsed. Before expanding/collapsing an item, the control fires the BeforeExpandItem event. Use the BeforeExpandIvent to cancel expanding/collapsing of an item. After item was expanded/collapsed the control fires the AfterExpandItem event. The following samples shows how to expand the selected item: Tree1.Items.ExpandItem(Tree1.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 ExpandOnKeys property to specify whether the user expands or collapses the focused items using arrow keys. Use the InsertItem property to add child items.
The following VB sample programmatically expands the item when the user selects it :
Private Sub Tree1_SelectionChanged() Tree1.Items.ExpandItem(Tree1.Items.SelectedItem()) = True End Sub
The following VB sample expands programmatically the focused item:
With Tree1.Items .ExpandItem(.FocusItem) = True End With
The following C++ sample expands programmatically the focused item:
#include "Items.h" CItems items = m_tree.GetItems(); items.SetExpandItem( items.GetFocusItem(), TRUE );
The following VB.NET sample expands programmatically the focused item:
AxTree1.Items.ExpandItem( AxTree1.Items.FocusItem ) = True
The following C# sample expands programmatically the focused item:
axTree1.Items.set_ExpandItem( axTree1.Items.FocusItem, true );
The following VFP sample expands programmatically the focused item:
with thisform.Tree1.Items .DefaultItem = .FocusItem .ExpandItem( 0 ) = .t. endwith