CComboBox::SetItemDataPtr

Sets the 32-bit value associated with the specified item in a combo box to be the specified pointer (void*).

int SetItemDataPtr(  
   int nIndex,  
   void* pData  
);

Parameters

  • nIndex
    Contains a zero-based index to the item.

  • pData
    Contains the pointer to associate with the item.

Return Value

CB_ERR if an error occurs.

Remarks

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.

Example

// Set the data pointer of each item to be NULL. 
for (int i = 0; i < m_pComboBox->GetCount(); i+)
{
   m_pComboBox->SetItemDataPtr(i, NULL);
}

Requirements

Header: afxwin.h

See Also

Reference

CComboBox Class

Hierarchy Chart

CComboBox::DeleteItem

CComboBox::GetItemData

CComboBox::GetItemDataPtr

CComboBox::SetItemData

CB_SETITEMDATA

CComboBox::AddString

CComboBox::InsertString

Other Resources

CComboBox Members