property Items.NextVisibleItem (Item as HITEM) as HITEM

Retrieves the handle of next visible item.

 TypeDescription 
   Item as HITEM A long expression that indicates the item's handle.  
   HITEM A long expression that indicates the handle of the next visible item.  

Use the NextVisibleItem property to access the visible items. The NextVisibleItem property retrieves 0 if there are no more visible items.  Use the IsItemVisible property to check whether an item fits the control's client area. Use the FirstVisibleItem property to retrieve the first visible item.

The following VB sample enumerates all visible items:

Private Sub VisItems(ByVal c As EXG2ANTTLibCtl.G2antt)
    Dim h As HITEM
    With c.Items
        h = .FirstVisibleItem
        While Not (h = 0)
            Debug.Print .CellValue(h, 0)
            h = .NextVisibleItem(h)
        Wend
    End With
End Sub

The FormatColumn event is fired before displaying a cell, so you can handle the FormatColumn to display anything on the cell at runtime. This way you can display the row position, you can display the value using the currency format, and so on. The FireFormatColumn property allows the control to fire the FormatColumn event for the column. The Position property specifies the position of the column.

The following VB sample handles the FormatColumn event to display the row position:

Private Sub G2antt1_FormatColumn(ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal ColIndex As Long, Value As Variant)
    Value = G2antt1.Items.ItemPosition(Item)
End Sub 
Private Sub G2antt1_FormatColumn(ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal ColIndex As Long, Value As Variant)
    Value = G2antt1.ScrollPos(True) + RelPos(Item)
End Sub

Private Function RelPos(ByVal hVisible As Long) As Long
    With G2antt1.Items
        Dim h As Long, i As Long, n As Long
        i = 0
        n = .VisibleCount + 1
        h = .FirstVisibleItem
        While (i <= n) And h <> 0 And h <> hVisible
            i = i + 1
            h = .NextVisibleItem(h)
        Wend
        RelPos = i
    End With
End Function

The following C++ sample enumerates all visible items:

#include "Items.h"
CItems items = m_g2antt.GetItems();
long hItem = items.GetFirstVisibleItem();
while ( hItem )
{
	OutputDebugString( V2S( &items.GetCellValue( COleVariant( hItem ), COleVariant( long(0) ) ) ) );
	hItem = items.GetNextVisibleItem( hItem );
}

The following C# sample enumerates all visible items:

EXG2ANTTLib.Items items = axG2antt1.Items;
int hItem = items.FirstVisibleItem;
while ( hItem != 0 )
{
	object strCaption = items.get_CellValue(hItem, 0);
	System.Diagnostics.Debug.WriteLine( strCaption != null ? strCaption.ToString() : "" );
	hItem = items.get_NextVisibleItem(hItem);
}

The following VB.NET sample enumerates all visible items:

With AxG2antt1.Items
    Dim hItem As Integer
    hItem = .FirstVisibleItem
    While Not (hItem = 0)
        Debug.Print(.CellValue(hItem, 0))
        hItem = .NextVisibleItem(hItem)
    End While
End With

The following VFP sample enumerates all visible items:

with thisform.G2antt1.Items
	.DefaultItem = .FirstVisibleItem
	do while ( .DefaultItem <> 0 ) 
		wait window .CellValue( 0, 0 )
		.DefaultItem = .NextVisibleItem( 0 )	
	enddo
endwith

 


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