在窗体上绘背景图案

来源:互联网 发布:osx rar解压软件 编辑:程序博客网 时间:2024/04/30 09:16
在一个窗体上绘制背景图,是一项很有用的功能

首先在你的工程里添加背景图片,然后右击选择生成类型为嵌入式资源

记得添加名称空间
using System.Reflection;

然后获取嵌入式图片资源

1private Image backgroundImage;


2     backgroundImage = new    Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("BkgndImage.7009.gif"));  

 

 

最后一步就是绘制背景了

1protected override void OnPaint(PaintEventArgs e)
2        {
3              e.Graphics.DrawImage(backgroundImage, this.ClientRectangle, new Rectangle(0, 0, this.backgroundImage.Width, this.backgroundImage.Height), GraphicsUnit.Pixel);
4          }


原创粉丝点击