DOTNETBAR制作圆角窗体和圆角控件代码实例

 更新时间:2013年11月27日 10:26:46   作者:  
这篇文章主要介绍了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实现不了,以下是本人实现圆角窗体的代码

 

复制代码 代码如下:

 /// <summary>
        /// 重绘窗体为圆角
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DispenserForm_Paint(object sender, PaintEventArgs e)
        {
            Form form = ((Form)sender);
            List<Point> list = new List<Point>();
            int width = form.Width;
            int height = form.Height;

            //左上
            list.Add(new Point(0, 5));
            list.Add(new Point(1, 5));
            list.Add(new Point(1, 3));
            list.Add(new Point(2, 3));
            list.Add(new Point(2, 2));
            list.Add(new Point(3, 2));
            list.Add(new Point(3, 1));
            list.Add(new Point(5, 1));
            list.Add(new Point(5, 0));
            //右上
            list.Add(new Point(width - 5, 0));
            list.Add(new Point(width - 5, 1));
            list.Add(new Point(width - 3, 1));
            list.Add(new Point(width - 3, 2));
            list.Add(new Point(width - 2, 2));
            list.Add(new Point(width - 2, 3));
            list.Add(new Point(width - 1, 3));
            list.Add(new Point(width - 1, 5));
            list.Add(new Point(width - 0, 5));
            //右下
            list.Add(new Point(width - 0, height - 5));
            list.Add(new Point(width - 1, height - 5));
            list.Add(new Point(width - 1, height - 3));
            list.Add(new Point(width - 2, height - 3));
            list.Add(new Point(width - 2, height - 2));
            list.Add(new Point(width - 3, height - 2));
            list.Add(new Point(width - 3, height - 1));
            list.Add(new Point(width - 5, height - 1));
            list.Add(new Point(width - 5, height - 0));
            //左下
            list.Add(new Point(5, height - 0));
            list.Add(new Point(5, height - 1));
            list.Add(new Point(3, height - 1));
            list.Add(new Point(3, height - 2));
            list.Add(new Point(2, height - 2));
            list.Add(new Point(2, height - 3));
            list.Add(new Point(1, height - 3));
            list.Add(new Point(1, height - 5));
            list.Add(new Point(0, height - 5));

            Point[] points = list.ToArray();

            GraphicsPath shape = new GraphicsPath();
            shape.AddPolygon(points);

            //将窗体的显示区域设为GraphicsPath的实例
            form.Region = new System.Drawing.Region(shape);
        }
 

相关文章

  • 基于C#制作一个颜色拾取器

    基于C#制作一个颜色拾取器

    这篇文章主要为大家详细介绍了如何基于C#制作一个颜色拾取器,可以获取屏幕上任意位置像素的色值,文中的示例代码讲解详细,有需要的小伙伴可以了解下
    2024-01-01
  • 详解如何在C#中接受或拒绝Excel中的修订

    详解如何在C#中接受或拒绝Excel中的修订

    修订功能可以跟踪文档所有的修改,了解修改的过程,这对于团队协同文档编辑、审阅是非常有用的一个功能。本文将详细为您介绍如何接受或拒绝 Excel 中的修订,感兴趣的可以收藏一下
    2022-12-12
  • C#实现通过模板自动创建Word文档的方法

    C#实现通过模板自动创建Word文档的方法

    这篇文章主要介绍了C#实现通过模板自动创建Word文档的方法,详细讲述了C#生成Word文档的实现方法,是非常实用的技巧,需要的朋友可以参考下
    2014-09-09
  • C#实现身份证号码验证的方法

    C#实现身份证号码验证的方法

    这篇文章主要介绍了C#实现身份证号码验证的方法,通过封装的类文件实例化调用实现了对身份证号码的验证,是非常实用的技巧,需要的朋友可以参考下
    2014-11-11
  • C# 实现dataGridView选中一行右键出现菜单的示例代码

    C# 实现dataGridView选中一行右键出现菜单的示例代码

    这篇文章主要介绍了C# 实现dataGridView选中一行右键出现菜单,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2020-09-09
  • C#实现判断当前操作用户管理角色的方法

    C#实现判断当前操作用户管理角色的方法

    这篇文章主要介绍了C#实现判断当前操作用户管理角色的方法,涉及C#针对系统用户判断的相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下
    2015-08-08
  • C#实现Winform鼠标拖动窗口大小时设定窗口最小尺寸的方法

    C#实现Winform鼠标拖动窗口大小时设定窗口最小尺寸的方法

    这篇文章主要介绍了C#实现Winform鼠标拖动窗口大小时设定窗口最小尺寸的方法,涉及WinForm改变窗口大小时动态判断当前窗口尺寸的相关技巧,非常简单实用,需要的朋友可以参考下
    2015-11-11
  • C#实现利用Windows API读写INI文件的方法

    C#实现利用Windows API读写INI文件的方法

    这篇文章主要介绍了C#实现利用Windows API读写INI文件的方法,涉及C#针对ini文件的创建、读取及写入等操作技巧,具有一定参考借鉴价值,需要的朋友可以参考下
    2015-07-07
  • C#文件流读写和进度回调示例详解

    C#文件流读写和进度回调示例详解

    这篇文章主要给大家介绍了关于C#文件流读写和进度回调的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧。
    2018-03-03
  • 在.NET WebService中跨域CORS问题的解决方案

    在.NET WebService中跨域CORS问题的解决方案

    在现代的Web应用程序开发中,跨域资源共享(Cross-Origin Resource Sharing, CORS)问题是开发者经常遇到的一个挑战,在这篇博客中,我们将深入探讨如何在 .NET WebService 中解决CORS问题,帮助开发者顺利实现跨域请求,需要的朋友可以参考下
    2024-05-05

最新评论