HeaderPane
Main
Hide
Share Link
Print

EditSearchMode

Defines how the combo box control searches for a matching item as the user types.

C

int WINAPI SftBox_GetEditSearchMode(HWND hwndCtl);
void WINAPI SftBox_SetEditSearchMode(HWND hwndCtl, int mode);

C++

int CSftBox::GetEditSearchMode() const;
void CSftBox::SetEditSearchMode(int mode);

Parameters

hwndCtl

The window handle of the combo box control.

mode

Defines how the combo box searches for a matching item as the user types. The effect of mode depends on the combo box style.

Simple and dropdown combo box (the search is based on the complete text in the edit control portion and takes place each time the text is changed by the user):

SFTBOX_SEARCH_AUTOIf the text in the edit control portion matches the text of an item completely, that item is selected and its text replaces the text in the edit control portion. The caret position and the text selection in the edit control portion do not change. If no item matches, no item is selected. Upper and lower case characters are considered equal.
SFTBOX_SEARCH_NONENo item search takes place. The application can implement its own search by handling the SFTBOXN_EDITCHANGE and SFTBOXN_EDITUPDATE notifications.
SFTBOX_SEARCH_USERSame as SFTBOX_SEARCH_NONE.
SFTBOX_SEARCH_FIRSTThe first item with text starting with the text in the edit control portion is selected and scrolled into view. The text in the edit control portion is not changed. If no item matches, no item is selected. Upper and lower case characters are considered equal.
SFTBOX_SEARCH_AUTOCOMPLETEThe first item with text starting with the text in the edit control portion is selected and scrolled into view. The text in the edit control portion is completed with the text of the item found. The portion of the text that was not typed by the user is selected in the edit control, so it is replaced as the user continues typing. If no item matches, no item is selected and the text is not changed. Upper and lower case characters are considered equal.
SFTBOX_SEARCH_AUTO2Same as SFTBOX_SEARCH_AUTO, but dependent items of a collapsed parent item are not searched.
SFTBOX_SEARCH_FIRST2Same as SFTBOX_SEARCH_FIRST, but dependent items of a collapsed parent item are not searched.
SFTBOX_SEARCH_AUTOCOMPLETE2Same as SFTBOX_SEARCH_AUTOCOMPLETE, but dependent items of a collapsed parent item are not searched.

Dropdown list combo box (the search is based on the characters typed by the user while the combo box has the input focus):

SFTBOX_SEARCH_AUTOThe first item that starts with the character(s) typed within a short time period is selected. As the user types additional characters, the search continues. If the user pauses, the search ends and the next character typed starts a new search. This is the default.
SFTBOX_SEARCH_NONENo item search takes place. The application can implement its own search by handling the NM_SFTBOX_CHAR notification.
SFTBOX_SEARCH_USERSame as SFTBOX_SEARCH_NONE.
SFTBOX_SEARCH_FIRSTThe next item following the currently selected item that starts with the one single character typed is selected. The search does not wrap around to the first item.
SFTBOX_SEARCH_AUTOCOMPLETESame as SFTBOX_SEARCH_AUTO.
SFTBOX_SEARCH_AUTO2Same as SFTBOX_SEARCH_AUTO, but dependent items of a collapsed parent item are not searched.
SFTBOX_SEARCH_FIRST2Same as SFTBOX_SEARCH_FIRST, but dependent items of a collapsed parent item are not searched.
SFTBOX_SEARCH_AUTOCOMPLETE2Same as SFTBOX_SEARCH_AUTO2.

Returns

GetEditSearchMode returns the current search mode (see mode above).

Comments

The GetEditSearchMode and SetEditSearchMode functions define how the combo box searches for a matching item as the user types.

If an invalid mode value is specified, SFTBOX_SEARCH_NONE is used.

When a combo box is created, the search mode is SFTBOX_SEARCH_AUTO.

In a dropdown list combo box, an item found while the dropdown portion is hidden becomes the selected item immediately: the static portion is updated and the SFTBOXN_SELCHANGE notification is sent. While the dropdown portion is shown, the item found is selected in the dropdown portion and is accepted when the user closes the dropdown portion, for example using the Enter key.

The column that is searched is defined using SetEditSearchColumn.

In a simple or dropdown combo box, the search takes place before the SFTBOXN_EDITCHANGE notification is sent to the parent window, so the application can use GetCurSel to retrieve the item found while handling the notification.

With SFTBOX_SEARCH_AUTOCOMPLETE and SFTBOX_SEARCH_AUTOCOMPLETE2, the text is not completed when the user removes characters using the Backspace or Delete key. In this case, the search is performed like SFTBOX_SEARCH_FIRST. This is also the case if the searched column wraps text onto multiple lines (see SFTBOX_COLUMN, style, SFTBOX_WRAP).

With the modes SFTBOX_SEARCH_NONE and SFTBOX_SEARCH_USER, an application can modify the text of the edit control portion or select an item (see SetCurSel) while handling the SFTBOXN_EDITCHANGE or SFTBOXN_EDITUPDATE notification. Changes made to the edit control while handling one of these notifications do not generate additional notifications.

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

The text is compared using the locale defined using SetLocale.

No search takes place in a combo box using a virtual data source.

Examples

C View entire sample code

    SftBox_SetDropDownOptimalWidth(hwndBox, TRUE);// The dropdown is as wide as its columns
    SftBox_SetDisableNoScroll(hwndBox, TRUE);   // Scroll bars always shown, needed for the sizing box
    SftBox_SetShowResizer(hwndBox, TRUE);       // The user can resize the dropdown
    SftBox_SetDarkMode(hwndBox, SFTBOX_DARKMODE_AUTO);

    // The edit portion shows and searches this column.
    SftBox_SetEditSearchColumn(hwndBox, editColumn);
    // Typing completes the text with the first matching item.
    SftBox_SetEditSearchMode(hwndBox, SFTBOX_SEARCH_AUTOCOMPLETE);
    if (editColumn == COL_ABBR)
        SftBox_LimitText(hwndBox, 2);

    for (i = 0 ; i < STATE_COUNT ; ++i) {
        LONG index = SftBox_AddString(hwndBox, m_aStates[i].lpszName);
        SftBox_SetText(hwndBox, index, COL_ABBR, m_aStates[i].lpszAbbr);
        SftBox_SetText(hwndBox, index, COL_CAPITAL, m_aStates[i].lpszCapital);

C++ View entire sample code

    box.SetDropDownOptimalWidth(TRUE);  // The dropdown is as wide as its columns
    box.SetDisableNoScroll(TRUE);       // Scroll bars always shown, needed for the sizing box
    box.SetShowResizer(TRUE);           // The user can resize the dropdown
    box.SetDarkMode(SFTBOX_DARKMODE_AUTO);

    // The edit portion shows and searches this column.
    box.SetEditSearchColumn(editColumn);
    // Typing completes the text with the first matching item.
    box.SetEditSearchMode(SFTBOX_SEARCH_AUTOCOMPLETE);
    if (editColumn == COL_ABBR)
        box.LimitText(2);

    for (int i = 0 ; i < STATE_COUNT ; ++i) {
        LONG index = box.AddString(m_aStates[i].lpszName);
        box.SetText(index, COL_ABBR, m_aStates[i].lpszAbbr);
        box.SetText(index, COL_CAPITAL, m_aStates[i].lpszCapital);

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


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