注意事项:
引用命名空间:System.Drawing.Drawing2D
调用方法的事件: Form_Paint(窗体的Paint事件) Form_Resize Resize 事件也可加上
预览图:
winform圆角窗体代码,C#教程,Winform教程,IBC编程社区
代码:
[C#] 纯文本查看 复制代码 private void BeautiLoginForm_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);
}
private void BeautiLoginForm_Resize(object sender, EventArgs e)
{
Type(this, 25, 0.1);
} |