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

C#中渐变色的代码实例,用于自绘菜单

2010-08-24 14:08 204 查看
Graphics g = e.Graphics;
LinearGradientBrush brush = new LinearGradientBrush(this.ClientRectangle,Color.SkyBlue, Color.White, LinearGradientMode.Horizontal);

g.FillRectangle(brush, this.ClientRectangle);//画一个渐变色的块
brush.Dispose();

brush = new LinearGradientBrush(this.ClientRectangle, Color.DarkBlue, Color.White, LinearGradientMode.Horizontal);
g.DrawLine(new Pen(brush, 1), 0, 0, this.Width, 0);//渐变色线
g.DrawLine(new Pen(brush, 1), 0, this.Height-1, this.Width, this.Height-1);
brush.Dispose();
g.Dispose();

其中主要是引入LinearGradientBrush,在文件头部
using System.Drawing.Drawing2D;

【原创 /article/6193707.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: