This documentation is archived and is not being maintained.

CComboBox::SetItemData 

Sets the 32-bit value associated with the specified item in a combo box.


int SetItemData(
   int nIndex,
   DWORD_PTR dwItemData 
);

Parameters

nIndex

Contains a zero-based index to the item to set.

dwItemData

Contains the new value to associate with the item.

CB_ERR if an error occurs.

Use the SetItemDataPtr member function if the 32-bit item is to be a pointer.

// The pointer to my combo box.
extern CComboBox* pmyComboBox;

// Set the data of each item to be equal to its index.
for (int i=0;i < pmyComboBox->GetCount();i++)
{
   pmyComboBox->SetItemData(i, i);
}
Show: