Returns the index of the list item that matches the string specified.
Newlook Smartclient only.
listview object.FindItem(string[, matchType][, startIndex][, partial])
The FindItem method syntax has these parameters:
Part |
Description |
string |
Specifies the string to be matched. |
matchType |
Optional. A constant specifying where to search for the string. This argument may be set to one of the pre-defined matchType constants. If omitted, the string will be matched to the Text property of the ListItem. |
startIndex |
Optional. Specifies where the search will begin. This can be either an integer, string or object. If an integer is specified then the search will start at the ListItem whose Index is specified by this value. If a string is specified then the search will start at the item whose Text property matches this string. If startIndex is omitted, then this method will search from the first ListItem in the list. |
partial |
Optional. A boolean specifying whether the search has to match part or all of the found value. This argument may be set to one of the partial values. If omitted, false is assumed and a match will only occur if the value exactly equals the string specified. |
The matchType argument settings are:
Constant |
Value |
Description |
nllvwText |
0 |
(Default) Search for the string argument in the Text property of the ListItems. |
nllvwSubItem |
1 |
Search for the string argument in the Text property of the sub-items. |
nllvwTag |
2 |
Search for the string argument in the Tag property of ListItems. |
The partial argument settings are:
Value |
Description |
0 |
A match will occur if the value begins with the string specified. |
1 |
(Default) A match will only occur if the value exactly equals the string specified. |
This method can be used to provide a search tool for users to find items in a list view control, or if you wish to identify a particular item in the list view based on its text value.
The index of the matched ListItem object.
The following example returns the index of the first item with a Text property that matches the string specified by the user in the text box named txtString, and if found, selects the item and ensures that it is visible in the listview.
function ReturnIndex()
{
vSearchString = App.ActiveForm.txtString.Text;
vMatchType = App.ActiveForm.cmbMatchType.Text;
vStartIndex = App.ActiveForm.txtStartIndex.Text;
vPartial = App.ActiveForm.cmbPartial.Text;
vFoundItemIndex = App.ActiveForm.lvwGroceries.FindItem(vSearchString,vMatchType,vStartIndex,vPartial);
if (vFoundItemIndex >= 0)
{
App.ActiveForm.lvwGroceries.EnsureVisible(vFoundItemIndex,0);
App.ActiveForm.lvwGroceries.ListItems(vFoundItemIndex).Selected = true;
}
}
Key property | Tag property | Text property
© 2004-2021 looksoftware. All rights reserved.