Solved

Excel Ribbon Add-in - Combobox dynamically add items

Posted on 2010-11-23
9
2,052 Views
Last Modified: 2012-05-10
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

0
Comment
Question by:jppinto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34203824
Is this syntax not available?

cboDepartamentos.Items.Add
0
 
LVL 33

Author Comment

by:jppinto
ID: 34204759
No, it's not available.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34204956
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Accepted Solution

by:
xenacode earned 500 total points
ID: 34205279
This is the VS2010/VSTO4 syntax:

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

If you're working with an earlier version, let me know.

Pete
Xenacode Ltd
0
 
LVL 33

Author Comment

by:jppinto
ID: 34205668
I'm working with the 2008 version of VS.
0
 
LVL 6

Expert Comment

by:xenacode
ID: 34206274
that should be fine too
0
 
LVL 33

Author Closing Comment

by:jppinto
ID: 34211195
Thanks. Worked like a charm.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34211245
You said that the syntax

cboDepartamentos.Items.Add

is not available!
0
 
LVL 33

Author Comment

by:jppinto
ID: 34211988
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.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question