Solved

Excel Ribbon Add-in - Combobox dynamically add items

Posted on 2010-11-23
9
2,023 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
  • 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.Net - Windows UserName index and length error 4 29
Get Client IP on RDS - VB.NET 15 44
write xml in vb.net 2 24
C# LINQ ForEach() question 6 18
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now