日期:2014-05-17 浏览次数:21400 次
this.CreateGraphics().DrawLine(Pens.Black, new Point(100, 100), new Point(200, 200));
this.Refresh();
GraphicsPath gp = new GraphicsPath();
List<PointF> arrPoints = new List<PointF>();
arrPoints.Add(new PointF(0, 0));
arrPoints.Add(new PointF(100, 0));
arrPoints.Add(new PointF(100, 100));
gp.AddLines(arrPoints.ToArray());
gp.CloseFigure();
this.CreateGraphics().DrawPath(Pens.Black, gp);
Region r = new Region(gp);
button1.Region = r;
button1.BackColor = Color.Red;
------解决方案--------------------
GraphicsPath gp = new GraphicsPath();
List<PointF> arrPoints = new List<PointF>();
arrPoints.Add(new PointF(0, 0));
arrPoints.Add(new PointF(100, 0));
arrPoints.Add(new PointF(100, 100));
gp.AddLines(arrPoints.ToArray());
gp.CloseFigure();
this.CreateGraphics().DrawPath(Pens.Black, gp);
Region r = new Region(gp);
button1.Region = r;
button1.BackColor = Color.Red;