C#画半透明色实例,可用于自绘菜单等

Graphics g = ((PictureBox)sender).CreateGraphics();//创建画板
Rectangle rc = new Rectangle(10, 0, ((PictureBox)sender).Width - 20, ((PictureBox)sender).Height - 1);
g.DrawRectangle(new Pen(Color.DarkBlue), rc);//画一个框
SolidBrush sb=new SolidBrush(Color.FromArgb(60,255,255,255));//创建半透明画刷
rc = new Rectangle(11, 1, ((PictureBox)sender).Width - 21, ((PictureBox)sender).Height - 2);
g.FillRectangle(sb, rc);//填充

此处用到SolidBrush,要在引用处增加
using System.Drawing;

【原创 http://www.cnblogs.com/vic_lu/archive/2010/08/24/1807213.html 】

原文地址:https://www.cnblogs.com/vic_lu/p/1807213.html