Solved

Excel Ribbon Add-in - Combobox dynamically add items

Posted on 2010-11-23
9
2,084 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
Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

 
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

Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

690 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