Click to See Complete Forum and Search --> : Object Array
PaulJayKnight
July 6th, 2009, 06:18 PM
I have a form with a lot of PictureBoxes. I created an array of these by name, but when I index the array I cant assign an image to the indexed item. In fact all the indexes appear to be nothing. Is there a way to create an array of controls and access them from the array?
dglienna
July 6th, 2009, 08:21 PM
Control array of them? Please be descriptive, and add some of your code, so we know what you've tried.
' Use CODE TAGS like this
HanneSThEGreaT
July 7th, 2009, 09:22 AM
Paul, if I do this :
Public Class Form1
Private PicBox(4) As PictureBox
Private i As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PicBox(i) = New PictureBox
PicBox(i).Image = Image.FromFile("C:\" & i.ToString & ".bmp")
PicBox(i).Visible = True
PicBox(i).BorderStyle = BorderStyle.FixedSingle
PicBox(i).Left = 20 * (i * 2)
Me.Controls.Add(PicBox(i))
i = i + 1
End Sub
End Class
It seems to work fine :)
Can you show us your code, and how you implemented it perhaps ¿
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.