当前位置: 移动技术网 > IT编程>开发语言>c# > 解析C#中如何把控件的边框角画为圆弧

解析C#中如何把控件的边框角画为圆弧

2019年07月18日  | 移动技术网IT编程  | 我要评论

复制代码 代码如下:

private void draw(graphics graphics, control control)
        {
            float x = float.parse(control.width.tostring()) - 1;
            float y = float.parse(control.height.tostring()) - 1;
            pointf[] pointfs = {
                new pointf(2,     0),
                new pointf(x-2,   0),
                new pointf(x-1,   1),
                new pointf(x,     2),
                new pointf(x,     y-2),
                new pointf(x-1,   y-1),
                new pointf(x-2,   y),
                new pointf(2,     y),
                new pointf(1,     y-1),
                new pointf(0,     y-2),
                new pointf(0,     2),
                new pointf(1,     1)
                };

            graphicspath path = new graphicspath();
            path.addlines(pointfs);

            pen pen = new pen(color.fromargb(150, color.blue), 1);
            pen.dashstyle = dashstyle.solid;
            graphics.drawpath(pen, path);
        }


首先要把控件注册一个事件:控件名称.paint+=事件名称,然后把以上函数进行传参,如:draw(e.graphics, this.control);

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网