在Winform中设计圆形按钮(Design Circular Buttons in WinForm App C#)
程序员文章站
2022-07-11 11:52:50
...
using System;
using System.Collections.Generic;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
class CircularButton:Button
{
protected override void OnPaint(PaintEventArgs pevent)
{
GraphicsPath grPath = new GraphicsPath();
grPath.AddEllipse(0, 0, ClientSize.Width, ClientSize.Height);
this.Region = new System.Drawing.Region(grPath);
base.OnPaint(pevent);
}
}
}
之后按照以下设置就可以了