Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3231174
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:00:51+00:00 2026-05-17T17:00:51+00:00

I have a CComboBox control with several items and I need to remove some

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:00:51+00:00Added an answer on May 17, 2026 at 5:00 pm

    Adding or removing items does not change the number you passed to SetItemData(). GetItemData() returns the same number. You however need to pass the index of the item to DeleteString(). When lower numbered items were deleted before then the index will no longer match GetItemData(). If you lost track of the index of a specific item you want to delete then you need to iterate the items to find it back.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create several combo boxes to represent enumeration values. I want the
I have a user control with a ComboBox and a TextBox. Everything is working
In .net, I have an inherited control: public CustomComboBox : ComboBox I simply want
I have a ComboBox hosted in a ListView and I need changes in the
I have set up a dialog with several tabs. One of these contains twenty
We have a GUI of several frames that build their contents dynamically. Each frame
I have a form in VB.Net with Autoscroll enabled and several ComboBoxes within it.
I have a combobox where the SelectedValue on the combo is bound to a
i have an combox control defined with events in my mainpage.xaml <Grid x:Name=LayoutRoot> <ComboBox
I have a bunch of controls (textbox and combobox) on a form with toolstripcontainer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.