This documentation is archived and is not being maintained.

CListBox::SetItemData 

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


int SetItemData(
   int nIndex,
   DWORD_PTR dwItemData 
);

Parameters

nIndex

Specifies the zero-based index of the item.

dwItemData

Specifies the value to be associated with the item.

LB_ERR if an error occurs.

// The pointer to my list box.
extern CListBox* pmyListBox;

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