Solved

ArrayList to filla combo box

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

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…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

690 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