c# 自定义控件描边,把自定义控件的边搞成其他颜色的

2025-04-26 00:15:12
推荐回答(1个)
回答1:

在 paint 事件里面编写Graphics g = e.Graphics;Pen pen = new Pen(Color);//你想要的边框颜色
Point[] point = new Point[4];point[0] = new Point(0, 0);
point[1] = new Point(Width ,0);
point[2] = new Point(Width, Height );
point[3] = new Point(0, Height );g.DrawPolygon(pen, point); 就可以为你的控件 增加一个边框线