如何使用C#在winform上给窗体上色逐渐由黄变绿?
谢谢你的帮助
请您参考如下方法:
例子:
using System.Drawing;
using System.Drawing.Drawing2D;
public Form1() {
InitializeComponent();
this.DoubleBuffered = true;
this.ResizeRedraw = true;
}
protected override void OnPaintBackground(PaintEventArgs e) {
using (var lgb = new LinearGradientBrush(this.ClientRectangle, Color.Yellow, Color.Green, LinearGradientMode.Vertical))
e.Graphics.FillRectangle(lgb, this.ClientRectangle);
}
