【www.bbyears.com--WinForm】
网上看到的很多winform窗体圆角设计代码都比较累赘,这里分享一个少量代码就可以实现的圆角。主要运用了System.Drawing.Drawing2D。
效果图
代码如下
代码如下 privatevoidBeautiLoginForm_Paint(objectsender, PaintEventArgs e) { Type(this, 25, 0.1); } privatevoidType(Control sender,intp_1,doublep_2) { GraphicsPath oPath =newGraphicsPath(); oPath.AddClosedCurve(newPoint[] { newPoint(0, sender.Height / p_1), newPoint(sender.Width / p_1, 0), newPoint(sender.Width - sender.Width / p_1, 0), newPoint(sender.Width, sender.Height / p_1), newPoint(sender.Width, sender.Height - sender.Height / p_1), newPoint(sender.Width - sender.Width / p_1, sender.Height), newPoint(sender.Width / p_1, sender.Height), newPoint(0, sender.Height - sender.Height / p_1) }, (float)p_2); sender.Region =newRegion(oPath); } privatevoidBeautiLoginForm_Resize(objectsender, EventArgs e) { Type(this, 25, 0.1); }