c# - - - winform程序四个角添加圆角效果

winform 给窗体四个角添加圆角效果。

在窗体 Load 事件中添加如下代码:

c# 复制代码
// 创建了一个圆角矩形的路径,并将其设置为控件的形状
System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
int radius = 30;
path.AddArc(0, 0, radius, radius, 180, 90); // 左上角
path.AddArc(this.Width - radius, 0, radius, radius, 270, 90); // 右上角
path.AddArc(this.Width - radius, this.Height - radius, radius, radius, 0, 90); // 右下角
path.AddArc(0, this.Height - radius, radius, radius, 90, 90); // 左下角
this.Region = new System.Drawing.Region(path);

运行程序,查看效果。四个角都有 30 大小的圆角效果。

相关推荐
阿蒙Amon19 小时前
C#每日面试题-Array和ArrayList的区别
java·开发语言·c#
i橡皮擦21 小时前
TheIsle恐龙岛读取游戏基址做插件(C#语言)
开发语言·游戏·c#·恐龙岛·theisle
用户21991679703911 天前
C# 14 中的新增功能
c#
垂葛酒肝汤1 天前
放置挂机游戏的离线和在线收益unity实现
游戏·unity·c#
爱说实话1 天前
C# 20260112
开发语言·c#
无风听海1 天前
C#中实现类的值相等时需要保留null==null为true的语义
开发语言·c#
云草桑1 天前
海外运单核心泡货计费术语:不计泡、计全泡、比例分泡
c#·asp.net·net·计泡·海运
精神小伙就是猛1 天前
C# Task/ThreadPool async/await对比Golang GMP
开发语言·golang·c#