property Items.ItemByIndex (Index as Long) as HITEM

Retrieves the handle of the item given its index in Items collection..

 TypeDescription 
   Index as Long A long expression that indicates the index of the item.  
   HITEM A long expression that indicates the item's handle.  

Use the ItemByIndex to get the index of an item. Use the ItemCount property to count the items in the control. the Use the ItemPosition property to get the item's position. Use the ItemToIndex property to get the index of giving item. For instance, The ItemByIndex property is the default property for Items object, so the following statements are equivalents: G2antt1.Items(0), G2antt1.Items.ItemByIndex(0). 

The following VB sample enumerates all items in the control:

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

The following C++ sample enumerates all items in the control:

#include "Items.h"
CItems items = m_g2antt.GetItems();
COleVariant vtMissing; V_VT( &vtMissing ) = VT_ERROR;
for ( long i = 0; i < items.GetItemCount(); i++ )
{
	COleVariant vtItem( items.GetItemByIndex( i ) ), vtColumn( long(0) );
	CString strCaption = V2S( &items.GetCellValue( vtItem, vtColumn ) ), strOutput;
	strOutput.Format( "Cell: '%s'\n", strCaption );
	OutputDebugString( strOutput );
}

The following VB.NET sample enumerates all items in the control:

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

The following C# sample enumerates all items in the control:

EXG2ANTTLib.Items items = axG2antt1.Items;
for (int i = 0; i < items.ItemCount; i++)
{
	object caption = items.get_CellValue(items[i], 0);
	string strCaption = caption != null ? caption.ToString() : "";
	System.Diagnostics.Debug.WriteLine(strCaption);
}

The following VFP sample enumerates all items in the control:

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

 


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