Solved

addrange for hashset

Posted on 2013-12-24
8
193 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
  • 4
  • 4
8 Comments
 
LVL 62

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 62

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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

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

Dim strLeaderNameListString As HashSet(Of String)
0
 
LVL 62

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 62

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

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

17 Experts available now in Live!

Get 1:1 Help Now