locked
How to add item to CMFCToolBarComboBoxButton RRS feed

  • Question

  • Dear all,

    I have add two items ("Option1","Option2") to CMFCToolBarComboBoxButton in CMainFrame::OnToolbarReset()

    How to add extra items in CMFCToolBarComboBoxButton exclude CMainFrame::OnToolbarReset()?

    I use function CMFCToolBarComboBoxButton::AddItem(_T("OPTION3"))  while I click button in CFormView, the result m_lstItems = {count=3} , this value is what I want. but the CMFCToolBarComboBoxButton displayed in CMFCToolBar still 2 items...I don't know why...

    Please give me some help, any help would be greatly appreciated. :)




    Friday, June 10, 2011 6:43 AM

Answers

  • I did sth like this and it worked ok.

    CMainFrame* pmf = (CMainFrame*)AfxGetMainWnd();
    CMFCToolBarComboBoxButton *comboButton = (CMFCToolBarComboBoxButton*) pmf->m_wndToolbar.GetButton(INDEX_OF_COMBO); comboButton->AddItem(_T("new string"));

    PS.

     

    INDEX_OF_COMBO
    

     

    is index of replaced button by your comboBox.


     

     


    Krzysztof Gąsior
    • Marked as answer by 陸雲 Monday, June 13, 2011 1:18 AM
    Friday, June 10, 2011 7:37 PM

All replies

  • I did sth like this and it worked ok.

    CMainFrame* pmf = (CMainFrame*)AfxGetMainWnd();
    CMFCToolBarComboBoxButton *comboButton = (CMFCToolBarComboBoxButton*) pmf->m_wndToolbar.GetButton(INDEX_OF_COMBO); comboButton->AddItem(_T("new string"));

    PS.

     

    INDEX_OF_COMBO
    

     

    is index of replaced button by your comboBox.


     

     


    Krzysztof Gąsior
    • Marked as answer by 陸雲 Monday, June 13, 2011 1:18 AM
    Friday, June 10, 2011 7:37 PM
  • Dear DonCziken

    It work, thank you:)

    Monday, June 13, 2011 1:18 AM