property Items.RootItem ([Position as Long]) as HITEM

Retrieves the handle of the root item giving its index into the root items collection.

TypeDescription
Position as Long A long value that indicates the position of the root item being accessed.
HITEM A long expression that indicates the handle of the root item.

A root item is an item that has no parent (ItemParent() = 0). Use the RootCount property of to count the root items. Use the AddItem to add root items to the control. Use the InsertItem method to insert child items.

The following VB sample enumerates all root items:

Dim i As Long, n As Long
With G2antt1.Items
    n = .RootCount
    For i = 0 To n - 1
        Debug.Print .CellValue(.RootItem(i), 0)
    Next
End With

The following C++ sample enumerates all root items:

#include "Items.h"
CItems items = m_g2antt.GetItems();
for ( long i = 0 ; i < items.GetRootCount(); i++ )
{
	COleVariant vtItem( items.GetRootItem(i) ), vtColumn( long(0) );
	OutputDebugString( V2S( &items.GetCellValue( vtItem, vtColumn ) ) );
}

The following VB.NET sample enumerates all root items:

With AxG2antt1.Items
    Dim i As Integer
    For i = 0 To .RootCount - 1
        Debug.Print(.CellValue(.RootItem(i), 0))
    Next
End With

The following C# sample enumerates all root items:

for (int i = 0; i < axG2antt1.Items.RootCount; i++)
{
	object strCaption = axG2antt1.Items.get_CellValue(axG2antt1.Items.get_RootItem(i), 0);
	System.Diagnostics.Debug.WriteLine(strCaption != null ? strCaption.ToString() : "");
}

The following VFP sample enumerates all root items:

with thisform.G2antt1.Items
	local i
	for i = 0 to .RootCount - 1
		.DefaultItem = .RootItem(i)
		wait window nowait .CellValue(0,0)
	next
endwith