Export (0) Print
Expand All


Retrieves the application-supplied 32-bit value associated with the specified combo-box item.

DWORD_PTR GetItemData(
   int nIndex 
) const;



Contains the zero-based index of an item in the combo box's list box.

The 32-bit value associated with the item, or CB_ERR if an error occurs.

The 32-bit value can be set with the dwItemData parameter of a SetItemData member function call. Use the GetItemDataPtr member function if the 32-bit value to be retrieved is a pointer (void*).

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

// If any item's data is equal to zero then reset it to -1.
for (int i=0;i < pmyComboBox->GetCount();i++)
   if (pmyComboBox->GetItemData(i) == 0)
      pmyComboBox->SetItemData(i, (DWORD) -1);

Community Additions

© 2015 Microsoft