barlop
barlop

Reputation: 13790

Programmatically set the image of a panel to a jpg file that is not in resources?

How can I programmatically set the image of a panel to a jpg file (a non BMP), that is not in resources?

I know how to set it to a BMP file(not in resources) or a resource file, but how to set it to a JPG file (not in resources)?

Upvotes: 3

Views: 603

Answers (1)

Reza Aghaei
Reza Aghaei

Reputation: 125257

You can use Image.FromFile or Image.FromStream to load the image and then set it as background image of the panel:

this.panel1.BackgroundImage = Image.FromFile(@"d:\image.jpg");

Upvotes: 2

Related Questions