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

相关推荐
唐青枫5 小时前
C#.NET 定时任务与队列利器:Hangfire 完整教程
c#·.net
hez201011 小时前
Runtime Async - 步入高性能异步时代
c#·.net·.net core·clr
mudtools1 天前
.NET驾驭Word之力:玩转文本与格式
c#·.net
唐青枫1 天前
C#.NET 数据库开发提速秘籍:SqlSugar 实战详解
c#·.net
mudtools2 天前
.NET驾驭Word之力:理解Word对象模型核心 (Application, Document, Range)
c#·.net
大飞pkz2 天前
【设计模式】C#反射实现抽象工厂模式
设计模式·c#·抽象工厂模式·c#反射·c#反射实现抽象工厂模式
唐青枫2 天前
从入门到进阶:C#.NET Stopwatch 计时与性能测量全攻略
c#·.net
未来之窗软件服务3 天前
幽冥大陆(二)RDIFSDK 接口文档:布草洗涤厂高效运营的技术桥梁C#—东方仙盟
开发语言·c#·rdif·仙盟创梦ide·东方仙盟
1uther3 天前
Unity核心概念⑨:Screen
开发语言·游戏·unity·c#·游戏引擎
阿幸软件杂货间3 天前
Office转PDF转换器v1.0.py
开发语言·pdf·c#