Retrieves the number of items.
Type | Description | |||
Long | A long value that indicates the number of items into the Items collection. |
The ItemCount property counts the items in the control. Use the ItemByIndex property to access an item giving its index. Use the AddItem, InsertItem, InsertControlItem, PutItems or DataSource property to add new items to the control. Use ChildCount to get the number of child items.
The following VB sample enumerates all items in the control:
Dim i As Long, n As Long With Gantt1.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_gantt.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.GetCellCaption( vtItem, vtColumn ) ), strOutput; strOutput.Format( "Cell: '%s'\n", strCaption ); OutputDebugString( strOutput ); }
The following VB.NET sample enumerates all items in the control:
With AxGantt1 Dim i As Integer For i = 0 To .Items.ItemCount - 1 Debug.Print(.Items.CellCaption(.Items(i), 0)) Next End With
The following C# sample enumerates all items in the control:
EXGANTTLib.Items items = axGantt1.Items; for (int i = 0; i < items.ItemCount; i++) { object caption = items.get_CellCaption(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.Gantt1.Items local i for i = 0 to .ItemCount - 1 .DefaultItem = .ItemByIndex( i ) wait window nowait .CellCaption(0,0) next endwith