Load Picturebox images that were added to the project

  • Thread starter Thread starter IT@ECommunity
  • Start date Start date
I

IT@ECommunity

At run time I want to alternate the images in a picture box dependant on
some code. Add created a folder called graphics in my Project and dragged
the images there. Now at run time what is there location\path when they are
embedded into the project.

Thanks,
Phil
 
This is code I used to pull icons when they are embedded. I believe you do
the same except for the System.Drawing object you use. As long as your
object can accept a stream, you should be good to go.

Dim p As System.Reflection.Assembly
p = System.Reflection.Assembly.GetExecutingAssembly()
Icons(0) = New System.Drawing.Icon(p.GetManifestResourceStream(Me.GetType(),
"GreenBulb.ico"))
Icons(2) = New System.Drawing.Icon(p.GetManifestResourceStream(Me.GetType(),
"RedBulb.ico"))
Icons(1) = New System.Drawing.Icon(p.GetManifestResourceStream(Me.GetType(),
"YellowBulb.ico"))
Me.ntfSystemInfo.Icon = Icons(0)

Note: I seem to remember the "GreenBuild.ico" part being case sensitive. I
could be remembering wrong, it's been a while.

Hope it helps
Chris
 
Ok. I modified it to this:

Dim p As System.Reflection.Assembly
Dim Icons() As Icon

Private Sub ClaimsProcessStatus_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load

p = System.Reflection.Assembly.GetExecutingAssembly()
Icons(0) = New System.Drawing.Icon(p.GetManifestResourceStream(Me.GetType(),
CHECKMRK.ICO"))

PictureBox1.Image = Icons(0).ToBitmap

End Sub

But it errors off on the Icons(0) line with the following error.
'null' is not a valid value for stream
 
Oops. I must have changed the icons property to content at some point in
time.

It doesn't error off now but it does just show a black square. Is there
another control I should be using to show an Icon?
 
It is all good. I edited the icons background and changed the sizemode to
autosize.

Thanks for the help Chris
 
Back
Top