Solved

ArrayList to filla combo box

Posted on 2004-09-15
4
351 Views
Last Modified: 2012-06-27
Ive been working on this for sometime now

I keep getting errors.

All I want to do is fill the combo box from the arraylist

It is a 1 dimensional array called al
combobox is val_list


 Dim al As ArrayList
        al.Add("myval")
        al.Add(14343)


I can get it to show when the program loads but I get array errors when I try:
Protected Overrides Sub OnLoadSettings()
        ' Let mybase do its thing...
        MyBase.OnLoadSettings()
 
 Dim al As ArrayList
        al = CType(UserPreferences.GetPreference("ARRAYLIST", al), ArrayList)
        If al Is Nothing Then
            Console.WriteLine("Did not get ArrayList!")
        Else
            Console.WriteLine("Retrieved the ArrayList!")
            Dim i As Integer
            For i = 0 To al.Count - 1
                Console.WriteLine("  " & i.ToString & ": " & al.Item(i).ToString)
            Next
        End If

   
 to bind it the combo
or
fill the combo

Im losing my hair!!!!!
0
Comment
Question by:malanois
[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
  • 3
4 Comments
 
LVL 27

Expert Comment

by:planocz
ID: 12068724
Dim al As ArrayList
        al.Add("myval")
        al.Add(14343)


  Private Sub FillItems(ByVal cmb As ComboBox)
            cmb.DisplayMember = "MYArrayList:"
           for i = 0 to Arraylist.Count -1
            cmb.Items.Add(ai(i))
            next
 End Sub
0
 
LVL 27

Expert Comment

by:planocz
ID: 12068825
sorry: forgot to remove [ cmb.DisplayMember = "MYArrayList:"]

Dim al As ArrayList
        al.Add("myval")
        al.Add(14343)


  Private Sub FillItems(ByVal cmb As ComboBox)
            for i = 0 to Arraylist.Count -1
            cmb.Items.Add(ai(i))
            next
 End Sub
0
 

Author Comment

by:malanois
ID: 12068906
It still is not working

my combobox is called fav_list

 I tried this.


    Private Sub FillItems(ByVal cmb As ComboBox)

        Dim i As Integer
        For i = 0 To al.Count - 1
            fav_list.Items.Add(al(i))
        Next
    End Sub

and this under form load

fav_list.Items.Add(FillItems)
0
 
LVL 27

Accepted Solution

by:
planocz earned 125 total points
ID: 12068959
Private Sub FillItems(ByVal cmb As ComboBox)

        Dim i As Integer
        For i = 0 To al.Count - 1
            fav_list.Items.Add(al(i))
        Next
    End Sub


Example:   Fillitems(fav_list)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

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