CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Location
    West Sussex, England
    Posts
    1,939

    ComboBox problem?

    Hi All,

    I recently had a bug associated with a sorted Drop list ComboBox. I added the data to the box and also called SetItemData(index, value) on each of the items added. Reading back the values directly after the insert shows everything worked ok. But after leaving the routine that initialised the control, the ComboBox sorts its content and corrupts the SetItemData() values for each of the entries that are moved (the value gets set to 0). Is this a bug in the MFC/Combo box code ? If you switch off the sort in the properties, the problem does not persist, which is the solution I am using in the short term.

    Any ideas on how to solve this problem ?

    Thanks


    Roger Allen
    Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
    Please remember to rate useful answers. It lets us know when a question has been answered.

  2. #2
    Join Date
    Apr 1999
    Posts
    306

    Re: ComboBox problem?

    I think this a bug in your code rather than a bug in Microsoft guys' code. When you add an item to the sorted combo, your item is immediately placed somewhere. So you cannot use the last index as if it was its index. I think you should do something like -- add the item, get the item index using Find or something else, then use the item index.

    Make sense.


  3. #3
    Join Date
    May 1999
    Location
    West Sussex, England
    Posts
    1,939

    Re: ComboBox problem?

    Yeah,
    I think your right. Maybe I should start using my brain.


    Thanks


    Roger Allen
    Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
    Please remember to rate useful answers. It lets us know when a question has been answered.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured