Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ArrayList to filla combo box

Posted on 2004-09-15
4
Medium Priority
?
366 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 500 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

610 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