1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Combobox

Discussion in 'MFC' started by dannygan9, Dec 23, 2004.

  1. dannygan9

    dannygan9 Banned

    Joined:
    Dec 23, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    HI..

    I got 2 comboBoxes, when i select the 1st item in 1st combobox, then will list all sub items in 2nd combobox. Data can be in database or in program. Got any guideline or reference...


    Thanks!

    Cheers! Danny
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,292
    Likes Received:
    365
    Trophy Points:
    83
    To fill the combobox you need to use its AddString property. Attach a CComboBox control to the combo box and use the AddString property to add the necessary strings depending on the option selected in the first combo.

    Thanks and I hope it helps.
    Shabbir Bhimani
     
  3. dannygan9

    dannygan9 Banned

    Joined:
    Dec 23, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    i means at 1st combobox which got items called "A","B","C"
    When i selected "A", 2nd combobox only list out "A1","A2","A3" only....
    Please advise! thanks!
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,292
    Likes Received:
    365
    Trophy Points:
    83
    so are you asking at what event should you use the above code.
     
  5. dannygan9

    dannygan9 Banned

    Joined:
    Dec 23, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Yes, is it got this such thing? Can i do this?


    oid CIDComboDemoDlg::OnSelchangeCombo1()
    {

    m_eFruitVal = (eEnumeratedFruit)m_combo.GetCurSelData();

    switch (m_eFruitVal)
    {
    case eBanana: m_descriptionWnd.SetWindowText("Banana");

    for (int i=0;i < 20;i++)
    {

    pmyComboBox->AddString("Malaysia");

    }
    break;

    case eApple: m_descriptionWnd.SetWindowText("Apple");

    for (int i=0;i < 20;i++)
    {

    pmyComboBox->AddString("Malaysia");

    }
    break;
     
    Last edited: Dec 27, 2004
  6. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,292
    Likes Received:
    365
    Trophy Points:
    83
    Yes its currently looks correct to me.
     
  7. dannygan9

    dannygan9 Banned

    Joined:
    Dec 23, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0

    void CIDComboDemoDlg::OnSelchangeCombo1()
    {
    m_eFruitVal = (eEnumeratedFruit)m_combo.GetCurSelData();

    switch (m_eFruitVal)
    {
    case eBanana:
    for (int i=0;i < 20;i++)
    {

    m_combo1->AddString("YELLOW");break; //BUT PROGRAM HANG AFTER I SELECT "BANANA",
    }
    }
    }


    m_combo1->AddString("YELLOW");break //THIS ONE I LIKE TO INSERT AT 2ND COMBOBOX, BUT WILL HANG WILL HANG AT HERE!
     
  8. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,292
    Likes Received:
    365
    Trophy Points:
    83
    It should not hand but add 20 times and come out. I guess the error is at some other point.
     
  9. alok

    alok New Member

    Joined:
    Jul 24, 2004
    Messages:
    127
    Likes Received:
    2
    Trophy Points:
    0
    Occupation:
    S/W Engg
    Home Page:
    Moderator,DOn't you think this wrong forum for posting queries.

    this subforum is for posting project not queries.there separate forum for posting Queries

    Thanks
     
  10. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,292
    Likes Received:
    365
    Trophy Points:
    83
    I did not notice that. Now its Moved.
     

Share This Page