Solved

ArrayList to filla combo box

Posted on 2004-09-15
4
337 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
  • 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 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