設置了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();
        }

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM