Condividi tramite


CComboBox::GetItemData

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

DWORD_PTR GetItemData(
   int nIndex 
) const;

Parameters

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

Return Value

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

Remarks

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*).

Example

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

Requirements

Header: afxwin.h

See Also

Reference

CComboBox Class

Hierarchy Chart

CComboBox::SetItemData

CComboBox::GetItemDataPtr

CComboBox::SetItemDataPtr

CB_GETITEMDATA

Other Resources

CComboBox Members