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?
Printable View
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?
Yes, it is possible. I will just post the MSDN example
VB Code:
Private Sub InitializePictureBox() PictureBox1 = New PictureBox ' Set the location and size of the PictureBox control. Me.PictureBox1.Location = New System.Drawing.Point(70, 120) Me.PictureBox1.Size = New System.Drawing.Size(140, 140) Me.PictureBox1.TabStop = False ' Set the SizeMode property to the StretchImage value. This ' will shrink or enlarge the image as needed to fit into ' the PictureBox. Me.PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage ' Set the border style to a three-dimensional border. Me.PictureBox1.BorderStyle = BorderStyle.Fixed3D ' Add the PictureBox to the form. Me.Controls.Add(Me.PictureBox1) End Sub
Ok.....thanks!
And to remove the picturebox during run time, the code will be:
Me.controls.remove(Picturebox1) ? :)
Hehe, jup. Or simply PictureBox1.visible=false or PictureBox1.hide() if you want to keep it for future uses, references or so. Or PictureBox = Nothing to clear the picture itself.
Yup,ok....thanks for the tips! :p
Don't forget to resolve your thread from the Thread Tools menu.