user2605318
user2605318

Reputation: 29

How to Load an Image onto PictureBox in Visual Studio using C#

I have been trying to use the following code to Load an Image from My Resources to A picture Box on Visual Studio 2012 using C#.

pictureBox1.Load(Properties.Resources.Desert);

And I have been getting the following errors.

  1. The best overloaded method match for System.Windows.Forms.PictureBox.Load(string) has some invalid arguments
  2. Argument 1: cannot convert from System.Drawing.Bitmap to string

Upvotes: 0

Views: 10615

Answers (1)

Simon Whitehead
Simon Whitehead

Reputation: 65079

The Load method takes a string. You are directly passing it a resource which is a Bitmap.. this won't work.

Try this:

pictureBox1.Image = Properties.Resources.Desert;

This will directly set the image in the PictureBox to be the Bitmap in your resources.

Upvotes: 1

Related Questions