用c#中的PictureBox显示图像

ha.*_*.ed 1 c#

我在c#中编写下面的代码来显示图像PictureBox但是在运行应用程序时,没有显示任何内容......

请帮我解决这个问题.

这是我的代码:

    private void button1_Click(object sender, EventArgs e)
    {
        PictureBox p =new PictureBox();
        p.ImageLocation = "1.jpg"
        p.Location = new Point(100, 75);
    }
Run Code Online (Sandbox Code Playgroud)

Han*_*ant 9

添加此行:

  this.Controls.Add(p);
Run Code Online (Sandbox Code Playgroud)


Bur*_*imi 6

PictureBox.Image = new Bitmap("yourImage.jpg"); 
Run Code Online (Sandbox Code Playgroud)

支持的格式是: BMP, EMF, EXIF, GIF, ICON, JPEG, PNG, TIFF and WMF.