Share via


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.

Return Value

CB_ERR if an error occurs.

Remarks

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

Example

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

Requirements

Header: afxwin.h

See Also

Reference

CComboBox Class

Hierarchy Chart

CComboBox::GetItemData

CComboBox::GetItemDataPtr

CComboBox::SetItemDataPtr

CB_SETITEMDATA

CComboBox::AddString

CComboBox::InsertString

Other Resources

CComboBox Members