how to i create an array of listbox..list(0),list(1),etc.. like in vb 6
Printable View
how to i create an array of listbox..list(0),list(1),etc.. like in vb 6
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?
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:
Dim arrListBox(2) As ListBox
VB Code:
For i as Integer = 0 To 2 arrListBox(i) = New ListBox arrListBox.Location = New Point(0, i*20) arrListBox.Size = New Size(100, 100) Me.Controls.Add(arrListBox(i)) Next i
Or by using Listboxes that already exists on your form:
VB Code:
arrListBox(0) = lstHey arrListBox(1) = lstDonuts 'etc etc
thanks!!! this will surely help :)
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.