Syntax 2: For ListView controls
Description
Searches for the next item whose label matches the specified
search text.
Applies to
ListView controls
Syntax
|
1 |
listviewname.FindItem ( startindex, label, partial, wrap ) |
|
Argument |
Description |
|---|---|
|
listviewname |
The ListView control for which you want to search for |
|
startindex |
The index number from which you want your search to |
|
label |
The string that is the target of the search |
|
partial |
If set to true, the search looks for a partial label |
|
wrap |
If set to true, the search returns to the first index |
Return value
Integer.
Returns the index of the item found if it succeeds and -1 if an
error occurs.
Usage
The search starts from startindex + 1 by default. To search from
the beginning, specify 0.
If partial is set to true, the search string matches any label
that begins with the specified text. If partial is set to false, the
search string must match the entire label.
If wrap is set to true, the search wraps around to the first index
item after searching to the end. If wrap is set to false, the search
stops at the last index item in the ListView.
FindItem does not select the item it finds. You must use the
item’s selected property in conjunction with FindItem to select the
resulting match.
Examples
This example takes the value from a SingleLineEdit control and
passes it to FindItem:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
listviewitem l_lvi integer li_index string ls_label ls_label = sle_find.Text IF ls_label = "" THEN MessageBox("Error" , & "Enter the name of a list item") sle_find.SetFocus() ELSE li_index = lv_list.FindItem(0,ls_label, TRUE,TRUE) END IF IF li_index = -1 THEN MessageBox("Error", "Item not found.") ELSE lv_list.GetItem (li_index, l_lvi ) l_lvi.HasFocus = TRUE l_lvi.Selected = TRUE lv_list.SetItem(li_index,l_lvi) END IF |
See also