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 大小的圆角效果。

相关推荐
czhc11400756631 小时前
c# 1213
开发语言·数据库·c#
xiaoid2 小时前
C#向jave平台的API接口推送
c#·post·webapi
小猪快跑爱摄影3 小时前
【AutoCad 2025】【C#】零基础教程(三)——获取选中的 Entity 插件 =》 初识 Entity 派生类
c#·autocad
czhc11400756634 小时前
c#w 1214
开发语言·c#
用户298698530145 小时前
C# 中如何从 URL 下载 Word 文档:基于 Spire.Doc 的高效解决方案
后端·c#·.net
wangbing11255 小时前
将swagger在线文档转为word
microsoft·c#·word
mangge085 小时前
定时刷新已经登录过的网页c#
c#
走错路的程序员7 小时前
C语言单片机与C#上位机之间传递大量参数比较好的实践方案
c语言·单片机·c#
辜月廿七7 小时前
C#字符串相关知识
c#
波波0078 小时前
使用.NET 四步玩转 AI 绘图|不用Python、不买显卡
开发语言·c#·.net