Selects characters in the edit control of a combo box.

BOOL SetEditSel(
   int nStartChar,
   int nEndChar 



Specifies the starting position. If the starting position is set to –1, then any existing selection is removed.


Specifies the ending position. If the ending position is set to –1, then all text from the starting position to the last character in the edit control is selected.

Nonzero if the member function is successful; otherwise 0. It is CB_ERR if CComboBox has the CBS_DROPDOWNLIST style or does not have a list box.

The positions are zero-based. To select the first character of the edit control, you specify a starting position of 0. The ending position is for the character just after the last character to select. For example, to select the first four characters of the edit control, you would use a starting position of 0 and an ending position of 4.


This function is not supported by the Windows ComboBoxEx control. For more information on this control, see ComboBoxEx Controls in the Platform SDK.

See the example for CComboBox::GetEditSel.

Community Additions