渐变的窗口背景(C#2005)

来源:互联网 发布:js改变css样式 编辑:程序博客网 时间:2024/06/07 00:15
 using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Drawing.Drawing2D;//提供高级的二维和矢量图形功能namespace Example010_渐变的窗口背景{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void Form1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; Color FColor = Color.Blue;//渐变起始色 Color TColor = Color.Yellow;//渐变结束色 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(); } }}
原创粉丝点击