Solved

addrange for hashset

Posted on 2013-12-24
8
191 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
 

Author Comment

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

Dim strLeaderNameListString As HashSet(Of String)
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

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)…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

757 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

21 Experts available now in Live!

Get 1:1 Help Now