解析C#中如何把控件的边框角画为圆弧
程序员文章站
2024-02-15 10:05:34
复制代码 代码如下:private void draw(graphics graphics, control control)  ...
复制代码 代码如下:
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);
上一篇: 解析c#操作excel后关闭excel.exe的方法
下一篇: 哲学家就餐问题中的JAVA多线程学习