CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    May 1999
    Posts
    36

    CComboBox, SetCurSel... VC++ 5.0...bug??

    Hi,

    Here's the problem. I populate a combobox in a dlg with 16 strings. The combobox is not set to sort.

    The strings added in position 2 and 9 are the same. In the dlgbox OnInitDlg handler (after I fill the combo), I call m_ctrlCombo.SetCurSel(9). This function returns "9". If I call m_ctrlCombo.GetCount() I get 16. Why, then, when the dlg is displayed, is the 2nd item selected?

    Is there a bug?

    I'm using VC++ 5.0 (no SP's)

    Thanks for any help,

    Harvey Hawes

    Software Engineer
    BioScience Analysis Software Ltd.

    Masters Candidate
    Cardiovascular/Respiratory Sciences
    Faculty of Medicine
    University of Calgary
    Calgary, Alberta, Canada

  2. #2
    Guest

    Re: CComboBox, SetCurSel... VC++ 5.0...bug??

    Hello,

    Look on you help the fonction GetCount dont return the curant selected string index but the total number of string !

    Chainard Arnaud :
    At : [email protected]


  3. #3
    Join Date
    May 1999
    Posts
    318

    Re: CComboBox, SetCurSel... VC++ 5.0...bug??

    For me your code seems correct.
    The only thing i see is that you may have a string member variable linked to your listbox (using DDX). If after selected the item you used UpdateData(TRUE) and then UpdateData(FALSE) I think the second item will be selected (because of the same string value).

    If this do not solve your problem try to put a code sample in the faq.




  4. #4
    Guest

    Re: CComboBox, SetCurSel... VC++ 5.0...bug??

    Hi:
    this is a problem that i had meet.
    In fact the strings has been added,but not displayed
    when you put a combo box into the form,you click it,
    and you can drag its bottom to make it larger,and the
    problem is solved.
    sorry for my poor english.

    your friend:
    yaohaihong
    e-mail address:[email protected]





  5. #5
    Join Date
    May 1999
    Location
    Sydney, Australia
    Posts
    420

    Re: CComboBox, SetCurSel... VC++ 5.0...bug??

    If the strings can have the same value, why have them there IDENTIFIED by their test. Use the DWORD in the ComboBox instead...

    sally


  6. #6
    Join Date
    May 1999
    Posts
    36

    Re: CComboBox, SetCurSel... VC++ 5.0...bug?? That's it... but why?

    Hi,

    You got it right on. I stepped through the code, and had m_ctrlCombo.GetCurSel() in the watch window. It changes right after a call to UpdateData(FALSE) (which was called after UpdateData(TRUE)).

    I've never really understood what that function does. Maybe you could clear things up for me.

    Thanks,



    Harvey Hawes

    Software Engineer
    BioScience Analysis Software Ltd.

    Masters Candidate
    Cardiovascular/Respiratory Sciences
    Faculty of Medicine
    University of Calgary
    Calgary, Alberta, Canada

  7. #7
    Guest

    Re: CComboBox, SetCurSel... VC++ 5.0...bug?? That's it... but why?

    UpdateData(TRUE) retrieves the value from the fields to the members variables of your class bound to the fields using DDX.

    UpdateData(FALSE) makes the reverse. It means it puts the value from the member variables to the windows control.

    I hope this could help.



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