有几种不同的方法可以实现这一目标.一个是使用TransparencyKey(如在Nifle指出的帖子中).另一个是将Region对象分配给Region表单的属性:
System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
path.AddPolygon(new[]
{
new Point(20, 20),
new Point(40, 10),
new Point(180, 70),
new Point(160, 260),
new Point(80, 140)
});
path.AddEllipse(40, 40, 300, 300);
this.Region = new Region(path);
Run Code Online (Sandbox Code Playgroud)
请注意,坐标指的是窗口,而不是客户区.还要注意GraphicsPath默认情况下对象中的重叠图形如何相互"反转"(这可以通过设置来防止path.FillMode = FillMode.Winding).