A combo box is a single control that consists of a list box combined with a static or edit control. Depending on the style you use to create the list box, the list box can be displayed at all times, or the list box can be hidden until the user displays it. Except where noted, the mouse and keyboard interface for the edit field and list box of a combo box is identical to that of a standard edit control or list box.
The CBS_SIMPLE style creates a combo box with an edit field and a list box that is always displayed below the edit field. When the combo box has focus, the user can type in the edit field. If an item in the list box matches what the user has typed, the matching item moves to the top of the list box. The user can also select items from the list box by using the DOWN ARROW and UP ARROW keys or the mouse.
The CBS_DROPDOWN style is similar to CBS_SIMPLE except that the list box is displayed only if the user selects the icon next to the edit field or presses ALT+DOWN ARROW or ALT+UP ARROW. Even when the list box is hidden, the user can select items from the list box by using UP ARROW and DOWN ARROW.
A combo box created with the CBS_DROPDOWNLIST appears identical to a CBS_DROPDOWN combo box, except that the edit field is replaced with a static text field. Instead of typing in the edit field, the user can select items from the list box by typing the first letter of the item. Of course, the user can also use the UP ARROW and DOWN ARROW keys or the mouse to select items in the combo box.
You add and delete items to the list-box portion of a combo box in much the same way as a plain list box, but using the CB_ADDSTRING, CB_INSERTSTRING, CB_DIR, and CB_DELETESTRING messages. Windows also provides additional combo-box messages for retrieving the contents of the edit field, matching text with a list-box item, and dealing with the contents of the edit field.
Summary: Combo-box notification codes match the corresponding list-box codes.
In many respects, a combo box is quite similar to a list box in the way it reports the user's interaction with the control. All of the list-box notification codes have parallel combo-box notification codes. In addition to these, Windows sends notification codes to indicate the following:
The list box of the combo box is being dropped down (CBN_DROPDOWN).
The user has changed the text in the edit field, and Windows has updated the display (CBN_EDITCHANGE).
The user has changed the text in the edit field, but Windows has not yet updated the display (CBN_EDITUPDATE).
The combo box has lost input focus (CBN_KILLFOCUS). In the case of CBS_DROPDOWN and CBS_DROPDOWNLIST combo boxes, this causes Windows to remove the list box from the display.
The combo box has gained focus (CBN_SETFOCUS).
Like a list box, a combo box can be created with a fixed- or variable-height owner-draw style. In the case of combo boxes, however, the owner is responsible for drawing items in the list box and in the selection (edit or static) field. For example, if the user selects an item in the list box, the owner of the combo box receives a WM_DRAWITEM message for the list-box item (to draw it as selected) and another WM_DRAWITEM message for the selection field.
You can also designate the CBS_SORT style for a combo box; Windows sorts owner-draw combo boxes in the same manner as owner-draw list boxes.
There is no multicolumn style for combo boxes.