Hello guys. I made a picture box and i want like when a button is pressed , the BackgroundImage of Picture Box to be changed in a screenshot from my resources.

Look what i did:

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBox1.SelectedItem.Equals("Rocket Launcher I"))
                pictureBox1.BackgroundImage = "sa-mp-042.png";
        }

But i get error: Error2: Cannot implicitly convert type 'string' to 'System.Drawing.Image'

pictureBox1.BackgroundImage = Image.FromFile("sa-mp-042.png"); should work

Edited 6 Years Ago by jonsca: n/a

Hello guys. I made a picture box and i want like when a button is pressed , the BackgroundImage of Picture Box to be changed in a screenshot from my resources.

Look what i did:

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBox1.SelectedItem.Equals("Rocket Launcher I"))
                {
pictureBox1.BackgroundImage = property.resources.abc.png;
                }
           else
             {
                   pictureBox1.BackgroundImage = property.resources.xyz.png;
            }
        }
This article has been dead for over six months. Start a new discussion instead.