Visual Studio 2005 (Tools for Office) Embed jpeg in Windows form

Hi

Is there a way to embed a jpeg in a VS 2005 Windows form so that it is part of the project?

Thanks

Murray
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
 
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
You can certainly embed an image into a Project...and then access that image from a Form...not sure if that is what you are asking for?...

Click on Project --> Add Existing Item and add your image.
Now select your image in the "Solution Explorer" window.
Down below in the "Properties" window, change the "Build Action" property from "Content" to "Embedded Resource".

Then even use code like this to load the image at run-time:

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        PictureBox1.Image = New Bitmap(Me.GetType, "yourImageName.jpg")
    End Sub

End Class

Of course, you replace "yourImageName.jpg" with whatever the name of your embedded image is.

*** Note that this is one of the rare occasions where VB.Net IS actually case-sensitive. ***
0
All Courses

From novice to tech pro — start learning today.