Quantcast
Channel: isaced - C#
Viewing all articles
Browse latest Browse all 10

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

$
0
0

 

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


Viewing all articles
Browse latest Browse all 10

Trending Articles