C#-创建圆形/椭圆形按钮

创建圆形按钮挺简单的。

public class EllipseButton : Button
{
    protected override void OnPaint(PaintEventArgs pevent)
    {
        GraphicsPath gPath = new GraphicsPath();
        // 绘制椭圆形区域
        gPath.AddEllipse(0, 0, this.ClientSize.Width, this.ClientSize.Height);

        // 将区域赋值给Region
        this.Region = new System.Drawing.Region(gPath);

        base.OnPaint(pevent);
    }
}


来源:https://www.youtube.com/watch?v=U6ciI0Gtb44

猜你喜欢

转载自blog.csdn.net/zhanghui_hn/article/details/79371948
今日推荐