欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

在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);
        }
    }
}

之后按照以下设置就可以了

在Winform中设计圆形按钮(Design Circular Buttons in WinForm App C#)

参考视频链接:https://www.youtube.com/watch?v=U6ciI0Gtb44

相关标签: C#