C#动态实现按钮背景设置
时间:2014-12-10 21:21:53
收藏:0
阅读:307
1、使用Properties.Resources类,这种方法需要你事先已经将图片添加到项目中来了
双击Properties -->添加资源-->图片-->png/jpg
命名比如 :abc.png
然后在解决方案里面,删掉该图片,把要做背景的图片 拖进来,改成同名
代码 button2.BackgroundImage = 命名空间名.Properties.Resources.图片名称;
2、直接用项目路径来引用图片(不能继承到 exe文件里)
button.BackgroundImage =Bitmap.FromFile("f:\\5.png");
评论(0)