Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding items to Ribbon dropdown using VB.NET

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.

like image 871
marj Avatar asked Apr 12 '12 09:04

marj


2 Answers

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);
like image 125
Peter Majeed Avatar answered Sep 22 '22 20:09

Peter Majeed


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.

like image 25
gustav Avatar answered Sep 20 '22 20:09

gustav