none
How to get selected item from Ribbon Combobox in MS Word 2013 and C# RRS feed

  • Question

  • In my application I have combobox component in Ribbon. I set combobox items in designer (in Properties window). How can I get selected item from code?
    Monday, March 31, 2014 8:23 AM

Answers

  • Hello Lenkita,

    Please take a look at the Accessing the Ribbon at Run Time article in MSDN. It describes all possible ways for accessing your controls. Then look for the SelectedItemIndex or SelectedItem property. Also you may find the Customize Outlook UI with VSTO Ribbon designer (CSOutlookUIDesigner) sample project helpful.

    I'd recommend using the RibbonDropDown control instead of the RibbonComboBox. It provides the SelectionChanged event and the SelectedItem property. You can type anything inside RibbonComboBox, that is why it has the TextChanged event instead of the SelectionChanged event.  And since what you type into the box isn't necessarily among the items in the list, a SelectedItem property would not make any sense.
    If you really want to use a RibbonComboBox, you can use its Text property to access what is currently in the box.

    • Marked as answer by Lenkita Monday, March 31, 2014 6:43 PM
    Monday, March 31, 2014 9:44 AM