c#创建透明背景用户控件

来源:互联网 发布:淘宝如何买二手东西 编辑:程序博客网 时间:2024/05/20 00:11
using System.Drawing;using System.Drawing.Drawing2D;using System.Windows.Forms;namespace TransColorControl{    public sealed partial class CControl : Control    {        #region 构造函数        public CControl()        {            InitializeComponent();            SetStyle(ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint                     | ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);        }        #endregion        #region 重写属性        protected override CreateParams CreateParams        {            get            {                var result = base.CreateParams;                result.ExStyle |= 0x00000020;                return result;            }        }        #endregion        #region 重写方法        protected override void OnPaint(PaintEventArgs pe)        {            base.OnPaint(pe);            pe.Graphics.SmoothingMode = SmoothingMode.AntiAlias;            pe.Graphics.FillPie(new SolidBrush(Color.Blue), 0, 0, 30, 30, 0, 270);        }        #endregion    }}

0 0
原创粉丝点击