WINFROM窗体实现圆角

首先我们先看看效果图

接下来我们看看怎么实现

先把窗体的FromBorderStyle属性改成None。

接下来登录窗体代码代码:

添加一个窗体Paint事件,引用using System.Drawing.Drawing2D;

private void frmLogin_Paint(object sender, PaintEventArgs e)
{
Type(this, 25, 0.1);
}

private void Type(Control sender, int p_1, double p_2)
{
GraphicsPath oPath = new GraphicsPath();
oPath.AddClosedCurve(new Point[] {
new Point(0, sender.Height / p_1),
new Point(sender.Width / p_1, 0),
new Point(sender.Width - sender.Width / p_1, 0),
new Point(sender.Width, sender.Height / p_1),
new Point(sender.Width, sender.Height - sender.Height / p_1),
new Point(sender.Width - sender.Width / p_1, sender.Height),
new Point(sender.Width / p_1, sender.Height),
new Point(0, sender.Height - sender.Height / p_1) }, (float)p_2);
sender.Region = new Region(oPath);
}

再添加窗体Resize事件

private void frmLogin_Resize(object sender, EventArgs e)
{
Type(this, 25, 0.1);
}

原文地址:https://www.cnblogs.com/dakang1/p/9908415.html