Solved

Excel Ribbon Add-in - Combobox dynamically add items

Posted on 2010-11-23
9
1,986 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
 
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

11 Experts available now in Live!

Get 1:1 Help Now