protected override void OnPaintBackground(PaintEventArgs e)
2 {
3 LinearGradientBrush b = new LinearGradientBrush(this.ClientRectangle,
4 Color.Blue,Color.AliceBlue,90f); //線性漸變
5 e.Graphics.FillRectangle(b,this.ClientRectangle); // 填充窗體
6 b.Dispose(); // 釋放資源
7 }
8ide
//panel填充漸變背景色this
private void panel1_Paint(object sender, PaintEventArgs e)
{
LinearGradientBrush brush = new LinearGradientBrush(e.ClipRectangle, Color.Red, Color.Blue, LinearGradientMode.Horizontal);
e.Graphics.FillRectangle(brush, e.ClipRectangle);
}