在窗体中加入一下代码

  1. #region 窗体圆角的实现
  2. private void ComFrmBase_Resize(object sender, EventArgs e)
  3. {
  4. if (this.WindowState == FormWindowState.Normal)
  5. {
  6. SetWindowRegion();
  7. }
  8. else
  9. {
  10. this.Region = null;
  11. }
  12. }
  13.  
  14. public void SetWindowRegion()
  15. {
  16. System.Drawing.Drawing2D.GraphicsPath FormPath;
  17. FormPath = new System.Drawing.Drawing2D.GraphicsPath();
  18. Rectangle rect = new Rectangle(, , this.Width, this.Height);
  19. FormPath = GetRoundedRectPath(rect, );
  20. this.Region = new Region(FormPath);
  21. }
  22.  
  23. /// <summary>
  24. ///
  25. /// </summary>
  26. /// <param name="rect">窗体大小</param>
  27. /// <param name="radius">圆角大小</param>
  28. /// <returns></returns>
  29. private GraphicsPath GetRoundedRectPath(Rectangle rect, int radius)
  30. {
  31. int diameter = radius;
  32. Rectangle arcRect = new Rectangle(rect.Location, new Size(diameter, diameter));
  33. GraphicsPath path = new GraphicsPath();
  34.  
  35. path.AddArc(arcRect, , );//左上角
  36.  
  37. arcRect.X = rect.Right - diameter;//右上角
  38. path.AddArc(arcRect, , );
  39.  
  40. arcRect.Y = rect.Bottom - diameter;// 右下角
  41. path.AddArc(arcRect, , );
  42.  
  43. arcRect.X = rect.Left;// 左下角
  44. path.AddArc(arcRect, , );
  45. path.CloseFigure();
  46. return path;
  47. }
  48. #endregion

winfrom 实现窗体圆角的更多相关文章

  1. winform 窗体圆角设计

    网上看到的很多winform窗体圆角设计代码都比较累赘,这里分享一个少量代码就可以实现的圆角.主要运用了System.Drawing.Drawing2D. 效果图 代码如下. private void ...

  2. WinFrom 登录窗体 密码保存效果

    WinFrom 登录窗体 保存密码效果 开发CS程序的程序员都会遇到 今天突然想把这个功能加到我的项目中 之后总结下 不多说 上图   如果关闭程序 下次在登录的时候 用户名.密码会自动保留下来  一 ...

  3. WinForm 窗体圆角实现

    找了很多资料最后找到了, 表示感谢  为了扩散, 决定复制一份并加上自己尝试的一些方法…… 圆角窗体参考地址:https://blog.csdn.net/lllljz/article/details/ ...

  4. WinFrom子窗体向父窗体传值

    父窗框mainForm;子窗体childForm,利用事件进行传值 在子窗体中的操作: public event EventHandler accept;public string value; pr ...

  5. Winfrom子窗体刷新父窗体

    本人比较懒,直接从网上转载了一篇比较合适的文章,只是文章格式有点乱,地址是 http://aspnet.blog.163.com/blog/static/17515510920121126104433 ...

  6. winfrom向窗体中拖放图片并显示

    首先要设置窗体的AllowDrop属性为true.然后在窗体的DragEnter事件中添加如下代码:调用自定义的显示图片的方法. #region "在用鼠标将某项拖放到区域时事件" ...

  7. c# winfrom 子窗体分屏显示

    参考博客:https://blog.csdn.net/kailan818/article/details/8517126 实现代码: private void button1_Click(object ...

  8. winfrom控件圆角

    刚好用到这个功能,看了好些例子.我就不明白,简单的一个事,一些文章里的代码写的那个长啊,还让人看么. 精简后,就其实一点,只要有paint事件的组件,都可画圆角,没有的外面套一个panel就行了. u ...

  9. [Winfrom] 捕获窗体最大化、最小化和关闭按钮的事件

    const int WM_SYSCOMMAND = 0x112;const int SC_CLOSE = 0xF060;const int SC_MINIMIZE = 0xF020;const int ...

随机推荐

  1. Google发布移动网站设计原则

    Google 刚刚发布了由 Google 与 AnswerLab 联合打造,名为<Principles of Mobile Site Design: Delight Users and Driv ...

  2. Git提交项目到GitHub

    一.GitHub新建项目 1.进入Github首页,点击New repository新建一个项目 2.填写相应信息后点击create即可 Repository name: 仓库名称 Descripti ...

  3. 如何为 Go 设计一个通用的日志包

    需求 一个通用的日志包,应该满足以下几个需求: 兼容 log.Logger,标准库大量使用了 log.Logger 作为其错误内容的输出通道,比如 net/http.Server.ErrorLog,所 ...

  4. JavaScript数据结构-12.散列碰撞(线性探测法)

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  5. PTA (Advanced Level) 1014 Waiting in Line

    Waiting in Line Suppose a bank has N windows open for service. There is a yellow line in front of th ...

  6. 动态生成自定义控件ascx如何给ascx传值

    有机会看到有网友在论坛上发出问题: 在网页上的铵钮执行之后,动态加载的用户控件,如果没有处理好,会在子用户控件的铵钮被执行时抛弃.因此我们需要着重需要处理的关键点.同相子用户控件在动态加载之后,它的状 ...

  7. Toolstrip 工具栏控件

    工具栏是另一种获取应用程序主要功能的常用方法,比起菜单更直观.   Tool strip 控件是由system.Windows.forms.Toolstrip类提供的,作用是创建易于自定义的常用工具栏 ...

  8. centos开启防火墙端口

    1. 查看已打开的端口 # netstat -anp 2. 查看想开的端口是否已开 # firewall-cmd --query-port=80/tcp 若此提示 FirewallD is not r ...

  9. apache2.4和2.2 的一些区别

    指令的一些差异 其中的一些指令已经无效,如: Order Deny,Allow  Deny from all  Allow from all 取而代之的是: Deny from all  变成  Re ...

  10. oracle sum(col1) over(partition by col2 order by col3):实现分组递增汇总

    应公司业务要求,需要对数据进行分组汇总做辅助列进行查询 所以使用到了sum(col1) over(partition by col2 order by col3)函数,为了学习与提高在此进行记录. 1 ...