利用DOTNETBAR制作圆角窗体和圆角控件
1、
如果制作圆角窗体,窗体先继承DOTNETBAR的:public partial class Form2 : DevComponents.DotNetBar.Office2007Form
然后窗体里加上一个DONTERBAR的panel,然后设置panel为fill占满整个窗体
然后设置panel的CornerType为Rounded,然后窗体就变为圆角的了: panelEx1.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded;
2、
如果是圆角控件就照葫芦画瓢,把panel放在控件上面,然后设置为fill,再设置panel的CornerType为Rounded就变为圆角控件了
DOTNETBAR的button控件默认就可以设置为圆角按钮的
今天弄个了一天最后弄出了圆角窗体,可是不是用DOTNETBAR,原来DOTNETBAR实现不了,以下是本人实现圆角窗体的代码
1 /// <summary> 2 /// 重绘窗体为圆角 3 /// </summary> 4 /// <param name="sender"></param> 5 /// <param name="e"></param> 6 private void DispenserForm_Paint(object sender, PaintEventArgs e) 7 { 8 Form form = ((Form)sender); 9 List<Point> list = new List<Point>(); 10 int width = form.Width; 11 int height = form.Height; 12 13 //左上 14 list.Add(new Point(0, 5)); 15 list.Add(new Point(1, 5)); 16 list.Add(new Point(1, 3)); 17 list.Add(new Point(2, 3)); 18 list.Add(new Point(2, 2)); 19 list.Add(new Point(3, 2)); 20 list.Add(new Point(3, 1)); 21 list.Add(new Point(5, 1)); 22 list.Add(new Point(5, 0)); 23 //右上 24 list.Add(new Point(width - 5, 0)); 25 list.Add(new Point(width - 5, 1)); 26 list.Add(new Point(width - 3, 1)); 27 list.Add(new Point(width - 3, 2)); 28 list.Add(new Point(width - 2, 2)); 29 list.Add(new Point(width - 2, 3)); 30 list.Add(new Point(width - 1, 3)); 31 list.Add(new Point(width - 1, 5)); 32 list.Add(new Point(width - 0, 5)); 33 //右下 34 list.Add(new Point(width - 0, height - 5)); 35 list.Add(new Point(width - 1, height - 5)); 36 list.Add(new Point(width - 1, height - 3)); 37 list.Add(new Point(width - 2, height - 3)); 38 list.Add(new Point(width - 2, height - 2)); 39 list.Add(new Point(width - 3, height - 2)); 40 list.Add(new Point(width - 3, height - 1)); 41 list.Add(new Point(width - 5, height - 1)); 42 list.Add(new Point(width - 5, height - 0)); 43 //左下 44 list.Add(new Point(5, height - 0)); 45 list.Add(new Point(5, height - 1)); 46 list.Add(new Point(3, height - 1)); 47 list.Add(new Point(3, height - 2)); 48 list.Add(new Point(2, height - 2)); 49 list.Add(new Point(2, height - 3)); 50 list.Add(new Point(1, height - 3)); 51 list.Add(new Point(1, height - 5)); 52 list.Add(new Point(0, height - 5)); 53 54 Point[] points = list.ToArray(); 55 56 GraphicsPath shape = new GraphicsPath(); 57 shape.AddPolygon(points); 58 59 //将窗体的显示区域设为GraphicsPath的实例 60 form.Region = new System.Drawing.Region(shape); 61 }
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
· 上周热点回顾(2.17-2.23)