设置了winform的背景图片随窗体的变化而变化

 private void mainform_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
System.Drawing.Bitmap xzfy = new System.Drawing.Bitmap(Application.StartupPath + "//img/背景.png");
g.DrawImage(xzfy, this.ClientRectangle);
}
private void loadBackImage()
{
Bitmap bit = new Bitmap(this.Width, this.Height);
Graphics g = Graphics.FromImage(bit);
// g.DrawImage(this.pictureBox1.Image, new Rectangle(0, 0, bit.Width, bit.Height), 0, 0, this.pictureBox1.Image.Width, this.pictureBox1.Image.Height, GraphicsUnit.Pixel);
this.BackgroundImage = bit;
g.Dispose();
}

  

    private void mainform_SizeChanged(object sender, EventArgs e)
{
loadBackImage();
}

  

 private void mainform_Load(object sender, EventArgs e)
{
loadBackImage();
}

  

上一篇:移动端点击事件兼容问题,在pc端可以点,在手机上不可以点


下一篇:JVM学习(4)——全面总结Java的GC算法和回收机制---转载自http://www.cnblogs.com/kubixuesheng/p/5208647.html