The previous solutions have given information with useful references. I will point out a very, very handy method of the
CComboBox
class. That is
SetItemDataPtr
. If this were my problem, I would first assemble the collection of users, and then I would load the combo box. This method,
SetItemDataPtr
, lets you associate a pointer with an item in a combo box. There is another method,
SetItemData
, that lets you associate an integer with an item. These are used to make it easy to obtain a pointer to the data represented by the UI. That is done with the methods
GetItemDataPtr
and
GetItemData
. I highly recommend that you become familiar with these methods because they make it really easy to handle data in dialog classes. They are also available with the
CListBox
and
CListCtrl
classes so the same techniques can be used with all of these controls. The remarks about
SetItemDataPtr
in the docs linked previously explain why these methods are so useful :
Quote:
This pointer remains valid for the life of the combo box, even though the item's relative position within the combo box might change as items are added or removed. Hence, the item's index within the box can change, but the pointer remains reliable.