property Editor.FindItem (Value as Variant) as Variant
Finds an item given its value or caption.

 TypeDescription 
   Value as Variant A long expression that indicates the value of the item being searched, a string expression that indicates the caption of the item being searched. If searching for a caption ( string parameter ), it can starts with ">" character, and so the searching is case-insensitive. By default the searching is case-sensitive. For instance, FindItem("One") looks for the exactly caption "One", while if using as FindItem(">One"), it searches case-insensitive for the word "one".  
   Variant A string expression that indicates the caption of the item, if the Value is a long expression, a long expression that indicates the item's value if Value is a string expression.  

The FindItem property retrieves an empty ( VT_EMPTY ) value if no item was found. Use the FindItem property to search the caption of the predefined value, in case the Value parameter is a long expression, or look for the predefined value when the Value parameter is a string expression. Use the AddItem method to add predefined values. Use the InsertItem method to add predefined values as child items.

In case you are using Items.CellEditor, the following sample finds the caption of selected value within a cell's editor. For instance, the NewValue can be the NewValue parameter of the Change event:

With Grid1
    With .Items
        If (.HasCellEditor(Item, ColIndex)) Then
            Debug.Print ("Caption: " & .CellEditor(Item, ColIndex).FindItem(NewValue))
        End If
    End With
End With


In case you are using Column.Editor, the following sample finds the caption of selected value within a column's editor. For instance, the NewValue can be the NewValue parameter of the Change event:

With Grid1
    With .Columns
        Debug.Print ("Caption: " & .Item(ColIndex).Editor.FindItem(NewValue))
    End With
End With


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