Solved

addrange for hashset

Posted on 2013-12-24
8
195 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 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 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