开发者

how to color form Gradually from yellow to green

开发者 https://www.devze.com 2023-04-13 09:54 出处:网络
how to color form on winform us开发者_Go百科ing C# Gradually from yellow to green ? thanks for any helpExample:

how to color form on winform us开发者_Go百科ing C# Gradually from yellow to green ?

thanks for any help


Example:

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);
}


You can implement the draw event of the form. Make sure you double buffer to reduce flashing. Then draw a rectangle with a LinearGradientBrush.

This should get you started.

http://weblogs.asp.net/cfrazier/archive/2005/08/10/422179.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消