繁体   English   中英

在C#中使用PictureBox显示图像

[英]Display images with PictureBox in 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);
    }

添加此行:

  this.Controls.Add(p);
PictureBox.Image = new Bitmap("yourImage.jpg"); 

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

PictureBox的大小可能很小,而您的图像却太大(将SizeMode属性设置为“ StrechImage”),我使用的是透明背景的高分辨率PNG图标,花了一些时间才能弄清楚。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM