Reputation: 525
So I have a picture box. I want to change the picture in the box when its clicked. I want to call the image from the references of the program. Here is what I understand of the code to use: Here is a cut up snippet of what I am trying to do:
namespace Control
{
public partial class Form1 : Form
{
private void pictureBox1_Click(object sender, EventArgs e)
{
pictureBox.Image=Properties.Resources.mypic;
}
}
}
The problem is, while using winforms C#, Visual Studio is not recognizing the "Properties" part of that code.
I have tried this.Properties
, Form1.Properties
, and Control.Properties
.
I have also set the image properties in my resource list to embed as well.
Upvotes: 1
Views: 1232
Reputation: 12880
It doesn't know where the Properties class lives.
In the IDE:
Properties
This is easier (to me) than remembering what namespace different classes live in.
Upvotes: 1
Reputation: 597
Try
yourAppName.Properties.Resources.mypic;
Upvotes: 3