个人代码库の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;
            }
        }

转载于:https://www.cnblogs.com/AsionTang/archive/2010/11/20/1882814.html

猜你喜欢

转载自blog.csdn.net/weixin_34015860/article/details/93270765