Solved

addrange for hashset

Posted on 2013-12-24
8
196 Views
Last Modified: 2013-12-24
I have a hashset and would like to add it to a combobox.

So this works
Dim strLeaderNameListString() As String
ComboBox1.Items.Clear()
        ComboBox1.Text = Nothing
        Me.ComboBox1.Items.AddRange(strLeaderNameListString)
        ComboBox1.Select()

Anything close to make this work?
Dim strLeaderNameListString As HashSet(Of String)
ComboBox1.Items.Clear()
        ComboBox1.Text = Nothing
        Me.ComboBox1.Items.AddRange(strLeaderNameListString)
        ComboBox1.Select()
0
Comment
Question by:chadmanvb
[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
  • 4
8 Comments
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 39738146
Getting any errors? If so please post along with the inner exception.
0
 

Author Comment

by:chadmanvb
ID: 39738159
I get an error telling me:
ComboBox1.Items.AddRange(strPKGNameList)
Error      1      Value of type 'System.Collections.Generic.HashSet(Of String)' cannot be converted to '1-dimensional array of Object'.
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 39738194
Try changing this line in the code :

 Me.ComboBox1.Items.AddRange(strLeaderNameListString)

To This :

 Me.ComboBox1.Items.AddRange(strLeaderNameListString.ToArray())
0
Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

 

Author Comment

by:chadmanvb
ID: 39738205
I dont see .ToArray as being an option for

Dim strLeaderNameListString As HashSet(Of String)
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 39738211
What version of Visual Studio are you using?
0
 

Author Comment

by:chadmanvb
ID: 39738214
2010 pro and working with .net 4.0
0
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 39738225
Sorry my fault I gave you the wrong line to change. Change that line back and change the following line of code.

 Me.ComboBox1.Items.AddRange(strLeaderNameListString)

To this :

 Me.ComboBox1.Items.AddRange(strLeaderNameListString.ToArray())
0
 

Author Closing Comment

by:chadmanvb
ID: 39738289
Works great!
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CSS question 16 59
Can Selenium do Load Testing? 2 56
What are MicroServices? 4 65
How do you think this website does searches? 5 30
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
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:…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

738 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