Type | Description | |||
Item as HITEM | A HITEM expression that indicates the handle of the item where the bars are enumerated. | |||
Key as Variant | A String expression that indicates the key of the bar. | |||
Variant | A String expression that indicates the key of the next bar in the item, or empty if there is no next bar in the item |
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 the bars in the item ( h indicates the handle of the item ):
With G2antt1 If Not (h = 0) Then Dim k As Variant k = .Items.FirstItemBar(h) While Not IsEmpty(k) Debug.Print "Key = " & k k = .Items.NextItemBar(h, k) Wend End If End With
The following C++ sample enumerates the bars in the item ( h indicates the handle of the item ):
CItems items = m_g2antt.GetItems(); COleVariant vtBar = items.GetFirstItemBar(h) ; while ( V_VT( &vtBar ) != VT_EMPTY ) { OutputDebugString( V2S( &vtBar ) ); OutputDebugString( "\n" ); vtBar = items.GetNextItemBar( h, vtBar ); }
where the V2S function converts a Variant expression to a string:
static CString V2S( VARIANT* pv, LPCTSTR szDefault = _T("") ) { if ( pv ) { if ( pv->vt == VT_ERROR ) return szDefault; COleVariant vt; vt.ChangeType( VT_BSTR, pv ); return V_BSTR( &vt ); } return szDefault; }
The following VB.NET sample enumerates the bars in the item ( h indicates the handle of the item ):
With AxG2antt1 If Not (h = 0) Then Dim k As Object k = .Items.FirstItemBar(h) While TypeOf k Is String System.Diagnostics.Debug.Print(k.ToString) k = .Items.NextItemBar(h, k) End While End If End With
The following C# sample enumerates the bars in the item ( h indicates the handle of the item ):
object k = axG2antt1.Items.get_FirstItemBar(h); while ( k != null ) { System.Diagnostics.Debug.Print(k.ToString()); k = axG2antt1.Items.get_NextItemBar(h, k); }
The following VFP sample enumerates the bars in the item ( h indicates the handle of the item ):
With thisform.G2antt1 If Not (h = 0) Then local k k = .Items.FirstItemBar(h) do While !empty(k) ?k k = .Items.NextItemBar(h, k) enddo Endif EndWith
In VFP, please make sure that you are using non empty values for the keys. For instance, if you are omitting the Key parameter of the AddBar method, an empty key is missing. If you need to use the FirstItemBar and NextItemBar properties, you have to use non empty keys for the bars.