个人代码库の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;
            }
        }
作者:Asion Tang
凡是没有注明[转载]的文章,本Blog发表的文章版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/AsionTang/p/1882814.html