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 OnMouseEnter(EventArgs e) { Graphics g = this.CreateGraphics(); g.DrawEllipse(new Pen(Color.Blue), 0, 0, this.Width, this.Height); g.Dispose(); } }
然后生成解决方案,生成之后,工具箱里会有如下图:
这个组件就是新的Button,你直接拖到窗体上就好了,
这个是简单的,效果不满意可以随便画
时间: 2024-10-12 22:21:41