Results 1 to 5 of 5

Thread: [RESOLVED] [2005] array of listbox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    128

    Resolved [RESOLVED] [2005] array of listbox

    how to i create an array of listbox..list(0),list(1),etc.. like in vb 6

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: [2005] array of listbox

    You can't do control arrays in .NET, and you could search this forum on Control Arrays, and get some answers for the alternative....but heck, I have the feeling that there is a much better answer than that. What is it you are trying to do with multiple listboxes?
    My usual boring signature: Nothing

  3. #3
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2005] array of listbox

    VB Code:
    1. Dim arrListBox(2) As ListBox
    Now you'll have 3 listbox references, they are not set to an instance of an object, which you will have to do yourself, either by creating new listboxes like this:

    VB Code:
    1. For i as Integer = 0 To 2
    2.     arrListBox(i) = New ListBox
    3.     arrListBox.Location = New Point(0, i*20)
    4.     arrListBox.Size = New Size(100, 100)
    5.     Me.Controls.Add(arrListBox(i))
    6. Next i

    Or by using Listboxes that already exists on your form:

    VB Code:
    1. arrListBox(0) = lstHey
    2. arrListBox(1) = lstDonuts
    3. 'etc etc
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    128

    Re: [2005] array of listbox

    thanks!!! this will surely help

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: [2005] array of listbox

    Still wondering what you are doing with this. Listboxes are slow and awkward enough that I find it hard to believe that there is a situation where they could not be replaced by something more efficient.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width