Solved

ArrayList to filla combo box

Posted on 2004-09-15
4
329 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

772 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

12 Experts available now in Live!

Get 1:1 Help Now