Skip to main content
 首页 » 编程设计

c#之如何给表格上色 逐渐从黄色到绿色

2024年02月23日17cmt

如何使用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); 
}