How to retrieve Image from Resources folder of the project in C#

后端 未结 5 1191
一生所求
一生所求 2021-01-04 08:39

i Have some images in resources folder in my project but i want to change the picture box from these resource files of the project

5条回答
  •  清酒与你
    2021-01-04 09:29

    string img = null;
    
    private void btnShow_Click(object sender, EventArgs e)
    {
        string imgName;
        img = textBox1.Text;
        imgName = "images/" + img + ".jpg";
    
        if (imgName == null)
        {
            MessageBox.Show("no photo");
        }
        else if (imgName != null)
        {
            this.picBox1.Image = Image.FromFile("images/" + img + ".jpg");
        }
    }
    

提交回复
热议问题