如何:创建特定形状的窗体 (Visual C#)

更新:2007 年 11 月

下面的示例创建一个椭圆形的窗体。

示例

System.Drawing.Drawing2D.GraphicsPath shape = 
    new System.Drawing.Drawing2D.GraphicsPath();
shape.AddEllipse(0, 0, this.Width, this.Height);
this.Region = new System.Drawing.Region(shape);

编译代码

若要使用此代码,请将其复制到 Form1_Load 事件处理程序。

Form 类的 Region 属性是高级成员。

请参见

概念

在 Visual C# 中设计用户界面

其他资源

自定义、显示和打印 Windows 窗体

Visual C# 指导教程