property Items.FirstItemBar (Item as HITEM) as Variant
Gets the key of the first bar in the item.

 TypeDescription 
   Item as HITEM A HITEM expression that indicates the handle of the item where the bars are enumerated.  
   Variant A String expression that indicates the key of the first bar in the item, or empty if the item contains no bar.   
Use the FirstItemBar and NextItemBar methods to enumerate the bars inside the item. Use the ItemBar property to access properties of the specified bar. Use the AddBar method to add new bars to the item. Use the AddLink method to link a bar with another. Use the AllowCreateBar method to create new bars using the mouse. Use the RemoveBar method to remove a bar from an item. Use the ClearBars method to remove all bars in the item.

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.


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