HeaderPane
Main
Hide
Share Link
Print

FindString

Searches a string.

C

LONG WINAPI SftBox_FindString(HWND hwndCtl, LONG index, int col, LPCTSTR lpszText, BOOL fWrap);
LONG WINAPI SftBox_FindStringCase(HWND hwndCtl, LONG index, int col, LPCTSTR lpszText, BOOL fWrap);

C++

LONG CSftBox::FindString(LONG index, int col, LPCTSTR lpszText, BOOL fWrap) const;
LONG CSftBox::FindStringCase(LONG index, int col, LPCTSTR lpszText, BOOL fWrap) const;

Parameters

hwndCtl

The window handle of the combo box control.

index

The zero-based index of the item after which the search begins (the item itself is not searched first). If -1 is specified, the search starts at the first item (index 0).

col

The zero-based column number to be searched. If -1 is specified, all columns are searched.

lpszText

The string to be searched.

fWrap

Set to TRUE to continue the search at the first item once the last item has been searched, ending with item index. If FALSE is specified, the search ends at the last item, so no item is searched if index is the last item. This parameter is ignored if index is -1.

Returns

The return value is the zero-based index of the item where the string was found. -1 is returned if the string was not found or an error occurred.

Comments

The FindString and FindStringCase functions search a string.

The string lpszText is compared to the cell text (see GetText) of each item following the item described by index. The search is restricted to the column specified by col, or includes all columns if col is -1. If an item with matching text is found, its zero-based index is returned, otherwise -1 is returned.

If the cell text starts with the string in lpszText, it is considered a match. To find an exact match for lpszText use FindStringExact.

Using FindString, the comparison of lpszText and the cell text is not case sensitive. Using FindStringCase, the comparison is case sensitive. The strings are compared using the locale defined using SetLocale.

If only enabled items can be selected (see SFTBOX_CONTROL, fSelectEnabledItemsOnly), disabled items are not searched.

The FindStringEx function can also be used and allows additional search options. SelectString can be used to search and select an item.

The following examples use FindString:

lpszTextCell TextMatchComment
ABCabcYesSame string, case is ignored
abcabc123YesStarts with lpszText
abcThisabcNoDoesn't start with lpszText
abcabNoDoesn't contain the complete lpszText

In a combo box control using a virtual data source, these functions cannot be used and -1 is returned.

See Also C/C++ API | Categories | Notifications


Last Updated 11/21/2026 - (email)
© 2026 Softel vdm, Inc.