首页 > 代码库 > C#重新绘制按钮

C#重新绘制按钮

 public  class ButtonX:Button     {                         protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)            {                base.OnPaint(e);                System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();                path.AddEllipse(0, 0, this.Width, this.Height);                this.Region = new Region(path);                            }            protected override void onm ouseEnter(EventArgs e)            {                Graphics g = this.CreateGraphics();                g.DrawEllipse(new Pen(Color.Blue), 0, 0, this.Width, this.Height);                g.Dispose();            }                  }

然后生成解决方案,生成之后,工具箱里会有如下图:

这个组件就是新的Button,你直接拖到窗体上就好了,
这个是简单的,效果不满意可以随便画

C#重新绘制按钮