-
May 31st, 2006, 09:45 PM
#1
Thread Starter
Lively Member
Can pictureboxes be created during run time?
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?
-
May 31st, 2006, 09:57 PM
#2
Re: Can pictureboxes be created during run time?
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
-
Jun 1st, 2006, 11:40 PM
#3
Thread Starter
Lively Member
Re: Can pictureboxes be created during run time?
Ok.....thanks!
And to remove the picturebox during run time, the code will be:
Me.controls.remove(Picturebox1) ?
-
Jun 2nd, 2006, 04:15 AM
#4
Re: Can pictureboxes be created during run time?
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.
-
Jun 16th, 2006, 03:19 AM
#5
Thread Starter
Lively Member
Re: Can pictureboxes be created during run time?
Yup,ok....thanks for the tips!
-
Jun 16th, 2006, 03:44 AM
#6
Re: Can pictureboxes be created during run time?
Don't forget to resolve your thread from the Thread Tools menu.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|