您的位置:首页 > 编程语言 > C#

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

2010-11-20 22:36 309 查看
/// <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;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: