代码库のC#背景色渐变的功能
/// <summary>
/// 实现“背景色渐变”的功能。【尚不完善】
/// </summary>
/// <param name="e"></param>
protected override void OnPaintBackground(PaintEventArgs e)
{
int y, dy;
//y=this.Height-this.ClientRectangle.Height;
y = this.ClientRectangle.Location.Y;
dy = this.ClientRectangle.Height / 256;
for (int i = 255; i >= 0; i--)
{
Color c = new Color();
c = Color.FromArgb(Convert.ToInt32(textBox1.Text.ToString()), i,Convert.ToInt32(textBox2.Text.ToString()));
SolidBrush sb = new SolidBrush(c);
Pen p = new Pen(sb, 100);
e.Graphics.DrawRectangle(p,this.ClientRectangle.X, y, this.Width,y+dy);
y = y + dy;
}
}