个人代码库のC#背景色渐变的功能

/// <summary>
02 /// 实现“背景色渐变”的功能。【尚不完善】
03 /// </summary>
04 /// <param name="e"></param>
05 protected override void OnPaintBackground(PaintEventArgs e)
06 {
07     int y, dy;
08     //y=this.Height-this.ClientRectangle.Height;
09     y = this.ClientRectangle.Location.Y;
10     dy = this.ClientRectangle.Height / 256;
11     for (int i = 255; i >= 0; i--)
12     {
13         
14         Color c = new Color();
15         c = Color.FromArgb(Convert.ToInt32(textBox1.Text.ToString()), i,Convert.ToInt32(textBox2.Text.ToString()));
16         SolidBrush sb = new SolidBrush(c);
17         Pen p = new Pen(sb, 100);
18         e.Graphics.DrawRectangle(p,this.ClientRectangle.X, y, this.Width,y+dy);
19         y = y + dy;
20     }
21 }
原文地址:https://www.cnblogs.com/bingyun84/p/1897250.html