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 handle of the item being expanded or collapsed.
Boolean A boolean expression that indicates whether the item is expanded or collapsed.

Use ExpandItem property to programmatically expand or collapse an item, in TableView mode. 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: Grid1.Items.ExpandItem(Grid1.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. In CardView mode, use the ExpandCard property to expand or collapse a card.

The following VB sample expands the selected item: Grid1.Items.ExpandItem(Grid1.Items.SelectedItem()) = True.

The ExpandItem property has no effect if the item has no child items. Use ChildCount property to determine whether an item contains child nodes. Use the ItemHasChildren property to built a virtual grid. A virtual grid loads items when the the user expands an item. 

The following VB sample expands the selected item:

Private Sub Grid1_SelectionChanged()
    Grid1.Items.ExpandItem(Grid1.Items.SelectedItem()) = True
End Sub

The following VB sample expands programmatically the focused item:

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

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

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

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

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

The following C# sample expands programmatically the focused item:

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

The following VFP sample expands programmatically the focused item:

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