i was wondering if you could make a new picture box during run time or do you have to have the picture box already set and visible = false then just make it true. any help with making a new picture box would be great
thnx
john
creating a new picture boxim am trying to make a new picture box during run time
Page 1 of 1
7 Replies - 32916 Views - Last Post: 08 October 2008 - 07:19 PM
#26
Re: creating a new picture box
Posted 08 February 2007 - 02:41 PM
Yes, anything you can do in the designer can be done at runtime. Just have the code execute inside the Form Load event.
An example would be:
An example would be:
Dim newPictureBox As New PictureBox
newPictureBox.Image = Image.FromFile("C:\pathToYourImage\filename.jpg")
newPictureBox.Visible = True
newPictureBox.Top = 20
newPictureBox.Width = 100
newPictureBox.Height = 50
newPictureBox.Left = 10
'add control to form
Controls.Add(newPictureBox)
#27
Re: creating a new picture box
Posted 08 February 2007 - 02:57 PM
one question i have about that is what will the name of that picture box be
#28
Re: creating a new picture box
Posted 08 February 2007 - 03:22 PM
also could i make an array as a new picture box like this
the problem is that it only lets me do
not as a new picture box is that the same thing?
dim test(5) as new picture box
the problem is that it only lets me do
dim test (5) as picturebox
not as a new picture box is that the same thing?
#29
Re: creating a new picture box
Posted 08 February 2007 - 04:39 PM
orangeslide8, on 8 Feb, 2007 - 01:57 PM, said:
one question i have about that is what will the name of that picture box be
The name of the PictureBox is the name of the object given in the Dim statement, in this case newPictureBox.
To create an array of controls you must initialize each control independently of the others. That is why you cannot use the New keyword when declaring the array of controls.
Dim test(5) As PictureBox test(0) = New PictureBox test(1) = New PictureBox . . .etc.. Controls.Add(test(0)) Controls.Add(test(1))
Don't forget, if you create your controls in code then you must handle setting the properties in code like I showed you in the previous post.
#30
Re: creating a new picture box
Posted 09 February 2007 - 06:33 PM
i wrote
but it highlighted
and said that
NullReferenceExeption was Unhandled
i don't understand why its happening any help would be great
test(1) = New PictureBox
Test(1).Image = Image.FromFile("C:\documents and settings\rob crampton\desktop\red chip.tiff"
test(1).Width = 51
test(1).Height = 53
Test(1).Top = 373
Test(1).Left = 220
Test(1).visible = true
controls.Add(Chip(1))
but it highlighted
test(1) = New Picturebox
and said that
NullReferenceExeption was Unhandled
i don't understand why its happening any help would be great
#31
Re: creating a new picture box
Posted 08 October 2008 - 11:46 AM
jayman9, on 8 Feb, 2007 - 02:41 PM, said:
Yes, anything you can do in the designer can be done at runtime. Just have the code execute inside the Form Load event.
An example would be:
An example would be:
Dim newPictureBox As New PictureBox
newPictureBox.Image = Image.FromFile("C:\pathToYourImage\filename.jpg")
newPictureBox.Visible = True
newPictureBox.Top = 20
newPictureBox.Width = 100
newPictureBox.Height = 50
newPictureBox.Left = 10
'add control to form
Controls.Add(newPictureBox)
What happens when the project is sent to a different user or computer? The path name to the picture will not be the same. How can this be overcome?
#32
Re: creating a new picture box
Posted 08 October 2008 - 07:19 PM
place afolder in your project folder and place all those images when you deploy your project deploy the files in working folder of your exe
now use the
appl.path
oh it's in vb.net please move this post to vb.net
now use the
appl.path
oh it's in vb.net please move this post to vb.net
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|