Link to home
Start Free TrialLog in
Avatar of jppinto
jppintoFlag for Portugal

asked on

Excel Ribbon Add-in - Combobox dynamically add items

Hello,

I've a ribbon add-in for Excel where I have some buttons and some comboboxes. I know how to add items to the combobox in Visual Studio but I would like to load the items dynamically on startup reading the values from a textbox.

At the momment I have the following code but I need help on the part where I add the items to the cboDepartamentos combobox.

Can you please help me?

Thanks,

jppinto
Private Sub Ribbon1_Load(ByVal sender As Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonUIEventArgs) Handles Me.Load

        Dim fileName As String = "D:\TextFiles\Departamentos.txt"

        Dim lines() As String = IO.File.ReadAllLines(fileName)

        For Each line As String In lines
            'cboDepartamentos.Items.Add...   here's where I need help!

        Next
    End Sub

Open in new window

Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Is this syntax not available?

cboDepartamentos.Items.Add
Avatar of jppinto

ASKER

No, it's not available.
ASKER CERTIFIED SOLUTION
Avatar of xenacode
xenacode
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jppinto

ASKER

I'm working with the 2008 version of VS.
that should be fine too
Avatar of jppinto

ASKER

Thanks. Worked like a charm.
You said that the syntax

cboDepartamentos.Items.Add

is not available!
Avatar of jppinto

ASKER

I've tryed like this:

cboDepartamentos.Items.Add("Test") and it wasn't available but like this:

cboDepartamentos.Items.Add( _
    New Microsoft.Office.Tools.Ribbon.RibbonDropDownItem _
    With {.Label = line})

was OK.