I have a CComboBox
control with several items and I need to remove some of them, but the indexes of the remaining items should be preserved.
When the combo box is populated, the item data is set like so:
index = mycombo.AddString(temp);
mycombo.SetItemData(index, static_cast<DWORD>(count));
where count
is a loop counter, and should be equal to index
Now I want to remove some of the items later, but I need the index of each remaining item to stay the same. Is CComboBox::DeleteString(UINT nIndex)
what I should use? Its documentation says:
All items following nIndex now move down one position. For example, if a combo box contains two items, deleting the first item will cause the remaining item to now be in the first position. nIndex=0 for the item in the first position.
Is that talking about the physical location in the drop-down menu, or the index value associated with the item?
Is there another function that does what I need? Another solution altogether?