CB_INSERTSTRING message

Inserts a string or item data into the list of a combo box. Unlike the CB_ADDSTRING message, the CB_INSERTSTRING message does not cause a list with the CBS_SORT style to be sorted.

Parameters

wParam

The zero-based index of the position at which to insert the string. If this parameter is -1, the string is added to the end of the list.

lParam

A pointer to the null-terminated string to be inserted. If you create the combo box with an owner-drawn style but without the CBS_HASSTRINGS style, the value of the lParam parameter is stored rather than the string to which it would otherwise point.

Return value

The return value is the index of the position at which the string was inserted. If an error occurs, the return value is CB_ERR. If there is insufficient space available to store the new string, it is CB_ERRSPACE.

If the combo box has WS_HSCROLL style and you insert a string wider than the combo box, you should send a LB_SETHORIZONTALEXTENT message to ensure the horizontal scroll bar appears.

Requirements

Requirement Value
Minimum supported client
Windows Vista [desktop apps only]
Minimum supported server
Windows Server 2003 [desktop apps only]
Header
Winuser.h (include Windows.h)

See also

Reference

CB_ADDSTRING

LB_SETHORIZONTALEXTENT

CB_DIR