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

相关推荐
呆萌哈士奇1 天前
告别 throw exception!为什么 Result<T> 才是业务逻辑的正确选择
c#·.net
海底星光1 天前
c# 生产者消费者模式之内存/redis队列实现
redis·c#
kylezhao20191 天前
C# 中实现自定义的窗口最大化、最小化和关闭按钮
开发语言·c#
月巴月巴白勺合鸟月半1 天前
PDF转图片的另外一种方法
pdf·c#
m5655bj1 天前
使用 C# 对比两个 PDF 文档的差异
pdf·c#·visual studio
Never_Satisfied1 天前
C#插值字符串中大括号表示方法
前端·c#
wy3136228211 天前
C#——意框架(结构说明)
前端·javascript·c#
kylezhao20191 天前
C# 各种类型转换深入剖析
开发语言·c#
xb11321 天前
Winform控件样式
c#
作孽就得先起床1 天前
unity webGL导出.glb模型
unity·c#·游戏引擎·webgl