I have 2 CMFCRibbonComboBox on the same Panel in a Ribbon- Eg:
CMFCRibbonComboBox *individualComputers =
new CMFCRibbonComboBox(-1,FALSE, 100, "Individual Computers", -1);
individualComputers->AddItem("Computer 1");
individualComputers->AddItem("Computer 2");
individualComputers->AddItem("Computer 3");
individualComputers->SelectItem(0);
CMFCRibbonComboBox * groupNames =
new CMFCRibbonComboBox (-1, FALSE, 100, "Computer Group Names", -1);
groupNames->AddItem("GROUP 1");
groupNames->AddItem("GROUP 2");
groupNames->AddItem("GROUP 3");
groupNames->SelectItem(0);
CMFCRibbonPanel* pComputerGroups = cComputerGroups->AddPanel("All Groups");
//cComputerGroups is a Category
pComputerGroups->Add(individualComputers);
pComputerGroups->Add(groupNames);
The problem is that , when I select “Group 1” in the groupNames comboBox from the UI(USer Interface) , then even “Computer 1” from the group individualComputers is selected. How do I make each combobox group independent of the other? Thanks.
I suspect you didn’t want add your combobox to itself
individualComputers->Add(individualComputers);should perhaps bepComputerGroups->Add(individualComputers);Otherwise your bug is probably elsewhere in your command or updateUI handling code not shown. This is likely as you are using the same ID of -1 to identify both combo boxes.
Furthermore there is no overloaded constructor for
CMFCRibbonComboBoxwhich takes an additional two parameters as you have shown forgroupNames.In the future please show actual code which follows SSCCE
Edit: Made previously unaddressed comment bold as it is likely to be your remaining issue. Consider using
const UINT CB_COMP_ID = 1;andconst UINT CB_GROUP_ID = 2;then you can reference each combo box separately usingCB_COMP_IDorCB_GROUP_IDin the message map etc.