property Items.FindItem (Caption as Variant, [ColIndex as Variant], [StartIndex as Variant]) as Long
Finds an item, looking for Caption in ColIndex column. The searching starts at StartIndex item.

 TypeDescription 
   Caption as Variant A Variant expression that indicates the caption that is searched for.  
   ColIndex as Variant A long expression that indicates the column's index, or a string expression that indicates the column's caption or column's key.  
   StartIndex as Variant A long value that indicates the index of item from where the searching starts.  
   Long A long value that indicates the index of item found.  
Use the FindItem to search for an item. Finds a control's item that matches Caption( Item, ColIndex ) = Caption. The StartIndex parameter indicates the index from where the searching starts. If it is missing, the searching starts from the item with the 0 index. Use the AutoSearch property to enable incremental search feature within the column.

The following VB sample looks and selects the "Item 2":

With List1.Items
    Dim i As Long
    i = .FindItem("Item 2",0)
    If (i >= 0) Then
        .SelectItem(i) = True
    End If
End With

The following C++ sample looks and selects the "Item 2":

CItems items = m_list.GetItems();
COleVariant vtMissing; vtMissing.vt = VT_ERROR;
int i = items.GetFindItem( COleVariant("Item 2"), COleVariant( long(0) ), vtMissing );
if ( i >= 0 )
	items.SetSelectItem( i, TRUE );

The following VB.NET sample looks and selects the "Item 2":

With AxList1.Items
    Dim i As Integer = .FindItem("Item 2", 0)
    If (i >= 0) Then
        .SelectItem(i) = True
    End If
End With

The following C# sample looks and selects the "Item 2":

int i = axList1.Items.get_FindItem("Item 2", 0, null);
if (i >= 0)
	axList1.Items.set_SelectItem(i, true);

The following VFP sample looks and selects the "Item 2":

With thisform.List1.Items
    local i
    i = .FindItem("Item 2",0)
    If (i >= 0) Then
        .SelectItem(i) = .t.
    EndIf
EndWith

 


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