在C#填充窗体为渐变颜色

时间:2014-07-18 20:31:38   收藏:0   阅读:234

protected override void OnPaintBackground(PaintEventArgs e)
2bubuko.com,布布扣  {
3bubuko.com,布布扣   LinearGradientBrush b = new LinearGradientBrush(this.ClientRectangle,
4bubuko.com,布布扣    Color.Blue,Color.AliceBlue,90f); //线性渐变
5bubuko.com,布布扣   e.Graphics.FillRectangle(b,this.ClientRectangle); // 填充窗体
6bubuko.com,布布扣   b.Dispose(); // 释放资源
7bubuko.com,布布扣  }
8bubuko.com,布布扣

 

 //panel填充渐变背景色

private void panel1_Paint(object sender, PaintEventArgs e)
{
LinearGradientBrush brush = new LinearGradientBrush(e.ClipRectangle, Color.Red, Color.Blue, LinearGradientMode.Horizontal);
e.Graphics.FillRectangle(brush, e.ClipRectangle);
}

在C#填充窗体为渐变颜色,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!