?
Solved

Excel Ribbon Add-in - Combobox dynamically add items

Posted on 2010-11-23
9
Medium Priority
?
2,126 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
AWS Certified Solutions Architect - Associate

This course has been developed to provide you with the requisite knowledge to not only pass the AWS CSA certification exam but also gain the hands-on experience required to become a qualified AWS Solutions architect working in a real-world environment.

 
LVL 6

Accepted Solution

by:
xenacode earned 2000 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

How To Install Bash on Windows 10

Windows’ budding partnership with Canonical has certainly led to some great improvements. One of them being the ability to use Bash on your Windows machine without third party applications! This might be one of the greatest things a cloud engineer in a Windows environment can do!

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

741 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