


In this article and in attached source code samples, CGroupComboBox is the class derived from CComboBox in which issues discussed below are implemented. If control is created with CBS_SORTED flag set, it is necessary to override the CompareItem() method too, in order to provide correct sorting of items. The DrawItem() method is invoked sequentially for each item displayed in the drop-down list. If combo box is created with CBS_OWNERDRAWFIXED style, heights of all items are equal and only DrawItem() method needs to be overridden. Conceptually, a new class must be derived from CComboBox class and several methods overridden in the derived class. Owner-drawn combo box allows distinct drawing of each individual item. Automatically Selecting Matching Item on List Dropdown.These issues will be discussed and solution for them proposed in this article. However, there were several additional issues to solve (like header item must not be selectable). I have not found any implementation that would meet such requirements, so I decided to create one.Ī prerequisite to draw headers that visually distinguish from other items imposed the use of owner-drawn combo box. On the other hand, list of all available items must be sorted alphabetically. Items recently used must be sorted chronologically, with the most recent item placed first. I needed a control similar to the font combo box in Microsoft Word products: to display a list of recently used items and a list of all available items in separate groups bounded by headers.
