5
votes

I am new to developing Excel VSTO solutions and need a little help on how to add further items to a dropdown control on the ribbon.

So far I have been able to create a number of items manually and then afterwards change the label of these items using

Globals.Ribbons.Ribbon1.DropDown1.Items(i).Label

Furthermore I found that some recommend using this to add further items to the dropdown control. But I am having a hard time trying to understand how to use it.

Globals.Factory.GetRibbonFactory.CreateRibbonComboBox.Items.Add

I would like to see a sample of how others have done it.

2

2 Answers

8
votes

Looks like you're on the right track. You need to first use the factory to create a new RibbonDropDownItem, give the new control the label you want, and then add the control to the parent ComboBox.

RibbonDropDownItem rdi = 
    Globals.Factory.GetRibbonFactory().CreateRibbonDropDownItem();
rdi.Label = "My Label";
Globals.Ribbons.Ribbon1.DropDown1.Items.Add(rdi);
3
votes

Awesome, on my need, i use :

dim rdi as RibbonDropDownItem
rdi = Globals.Factory.GetRibbonFactory().CreateRibbonDropDownItem()
rdi.label = "myList"
Globals.Ribbon.Tab.DDlist.Item.Add(rdi)

Now, i need to to use a string array as label of DropDownItem.