【WinForm】控件动态添加图片

以下方法适用于大部分控件。

一、使用Properties.Resources类

需要你事先将图片添加到项目中。添加方法如下:

 

 

 button.BackgroundImage = 命名空间名.Properties.Resources.图片名称;

 

二、使用图片链接

button.BackgroundImage =Bitmap.FromFile("d:\\123.png");

 

posted @ 2023-02-02 16:59  不溯流光  阅读(493)  评论(0编辑  收藏  举报