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 VisibleItemCount property to specify the number of visible items in the list. Use the ItemByIndex property to get the handle of the item giving its index. Use ChildCount to get the number of child items giving an item. Use the ItemChild property to get the first child item. Use the FirstVisibleItem property to get the first visible item. Use the NextVisibleItem property to get the next visible item. The NextSiblingItem property retrieves the next sibling of the item in the parent's child list. Use the ItemPosition property to change the item's position. Use the AddItem, InsertItem, PutItems or DataSource property to add new items to the control. Use ChildCount to get the number of child items.
The following VB.NET sample enumerates all items and bars in the control (/NET or /WPF version):
With Exg2antt1 Dim i, h As Integer, key As Object For i = 0 To .Items.ItemCount - 1 h = .Items(i) key = .Items.get_FirstItemBar(h) While TypeOf key Is String Debug.Print("Key = " & key & ", Item " & .Items.get_CellCaption(h, 0)) key = CStr(.Items.get_NextItemBar(h, key)) End While Next End With
The following C# sample enumerates all items and bars in the control (/NET or /WPF version):
for (int i = 0; i < exg2antt1.Items.ItemCount; i++) { int h = exg2antt1.Items[i]; object key = exg2antt1.Items.get_FirstItemBar(h); while (key != null) { System.Diagnostics.Debug.Print("Key = " + key + ", Item " + exg2antt1.Items.get_CellCaption(h, 0)); key = exg2antt1.Items.get_NextItemBar(h, key); } }
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