Syntax 2 For ListView controls
Description
Searches for the next item whose label matches the specified
search text.
Controls
ListView controls
Syntax
|
1 |
<span>listviewname</span><span>.FindItem</span> ( <span>startindex, label, partial, wrap</span> ) |
|
Argument |
Description |
|---|---|
|
listviewname |
The ListView control for which you want |
|
startindex |
The index number from which you want |
|
label |
The string that is the target of the |
|
partial |
If set to true, the |
|
wrap |
If set to true, the |
Return Values
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 |
listviewitem l_lvi |
|
1 |
integer li_index |
|
1 |
string ls_label |
|
1 |
|
1 |
ls_label = sle_find.Text |
|
1 |
IF ls_label = "" THEN |
|
1 |
MessageBox("Error" , & |
|
1 |
"Enter the name of a list item") |
|
1 |
sle_find.SetFocus() |
|
1 |
ELSE |
|
1 |
li_index = lv_list.<span>FindItem</span>(0,ls_label, TRUE,TRUE) |
|
1 |
END IF |
|
1 |
IF li_index = -1 THEN |
|
1 |
MessageBox("Error", "Item not found.") |
|
1 |
ELSE |
|
1 |
lv_list.GetItem (li_index, l_lvi ) |
|
1 |
l_lvi.HasFocus = TRUE |
|
1 |
l_lvi.Selected = TRUE |
|
1 |
lv_list.SetItem(li_index,l_lvi) |
|
1 |
END IF |