软件编程
位置:首页>> 软件编程>> C#编程>> Winform窗体圆角设计代码

Winform窗体圆角设计代码

作者:Jurieo  发布时间:2022-04-22 18:15:30 

标签:Winform,圆角

网上看到的很多winform窗体圆角设计代码都比较累赘,这里分享一个少量代码就可以实现的圆角。主要运用了System.Drawing.Drawing2D

效果图

Winform窗体圆角设计代码

代码如下


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

代码比较简单,希望有所帮助。

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com