【C#】[窗体]渐变窗口背景

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D; //

namespace 渐变窗口背景
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        //窗体重绘事件
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            Color FColor = Color.LawnGreen;
            Color TColor = Color.Green;
            Brush b = new LinearGradientBrush(this.ClientRectangle, FColor, TColor, LinearGradientMode.ForwardDiagonal);
            g.FillRectangle(b, this.ClientRectangle);
        }

        //窗口调整大小事件
        private void Form1_Resize(object sender, EventArgs e)
        {
            this.Invalidate();
        }


    }
}

源码下载:http://download.csdn.net/source/3001722

posted @ 2011-01-25 14:35  isaced  阅读(741)  评论(0编辑  收藏  举报