Click to See Complete Forum and Search --> : Is it possible to create Pictureboxes during run time?


ZhiYi
May 31st, 2006, 09:30 PM
Hi,

Is it possible to create Pictureboxes during run time?

During design time, there is only 1 picturebox on the form but when the application is running, I would like to add more pictureboxes 'on the fly'.

Can this be done in vb.net?

aniskhan
May 31st, 2006, 10:08 PM
intialize new pictureBox objectdim newPictureBox as PictureBox
newPictureBox= new PictureBox()set its properties
newPictureBox.Parent=me
newPictureBox.Location=new Point(10,10)
newPictureBox.Size=new Size(100,100)add it to parent controls
Me.Controls.Add(newPictureBox)

HanneSThEGreaT
June 1st, 2006, 01:09 AM
Dynamic Controls (http://msdn2.microsoft.com/en-us/library/t495d9x5.aspx)

ZhiYi
June 1st, 2006, 11:51 PM
Thanks for the replies! :o

And to remove controls during run time, the code will be:

Me.controls.remove(Picturebox1) right?