property Items.FindBar (BarKey as Variant, [StartIndex as Variant]) as HITEM
Finds the item that hosts the specified bar.

TypeDescription
BarKey as Variant A Variant expression that holds the key of the bar to look for.
StartIndex as Variant A Long expression that could be one of the following:
  • 0 or positive, specifies the index to start searching from. If missing, 0 is used instead. The FindBar method searches all unlocked items ( not including the locked items ).
  • -1, searches for specified task into locked-top, unlocked and locked-bottom items ( all-items ), and returns the handle of the item that holds the specified bar.
  • -2, searches for specified task into locked-top, and locked-bottom items ( locked-items ), and returns the handle of the item that holds the specified bar.
  • -3, searches for specified task into locked-top items, and returns the handle of the item that holds the specified bar.
  • -4 searches for specified task into locked-bottom items, and returns the handle of the item that holds the specified bar.
HITEM A Long expression that specifies the handle of the item that hosts the specified bar. If 0, the FindBar found no item that hosts a bar with specified key.
The FindBar property looks for the item that hosts the specified bar. The FindBar property returns 0 if no item has been found. The EnsureVisibleItem method ensures that an item fits the control's client area, and so the chart is vertically scrolled until the specified item fits the control's area. The ScrollTo method  scrolls horizontally the chart until the specified date fits the chart's client area. The ItemBar property accesses the properties of the specified bar.

The following VB sample ensures that specified bar fits the control's chart area ( for the /COM version ):

Private Sub ensureVisibleBar(BarKey)
    With G2antt1
        .BeginUpdate
        With .Items
            Dim h As HITEM
            h = .FindBar(BarKey)
            If (h <> 0) Then
                .EnsureVisibleItem h
                G2antt1.Chart.ScrollTo .ItemBar(h, BarKey, exBarStart), AlignmentEnum.CenterAlignment
            End If
        End With
        .EndUpdate
    End With
End Sub

The following VB/NET sample ensures that the specified bar fits the control's chart area ( the code is for the /NET Assembly version ):

Private Sub ensureVisibleBar(ByVal BarKey)
    With Exg2antt1
        With .Items
            Dim h As Integer = .get_FindBar(BarKey)
            If (h <> 0) Then
                Exg2antt1.BeginUpdate()
                .EnsureVisibleItem(h)
                Exg2antt1.Chart.ScrollTo(.get_BarStart(h, BarKey), exontrol.EXG2ANTTLib.AlignmentEnum.CenterAlignment)
                Exg2antt1.EndUpdate()
            End If
        End With
    End With
End Sub

The following C# sample ensures that the specified bar fits the control's chart area ( the code is for the /NET Assembly version ):

private void ensureVisibleBar(object barKey)
{
    int h = exg2antt1.Items.get_FindBar(barKey);
    if (h != 0)
    {
        exg2antt1.BeginUpdate();
        exg2antt1.Items.EnsureVisibleItem(h);
        exg2antt1.Chart.ScrollTo(exg2antt1.Items.get_BarStart(h, barKey), exontrol.EXG2ANTTLib.AlignmentEnum.CenterAlignment);
        exg2antt1.EndUpdate();
    }
}