在窗体的Paint事件中设定。注意不仅可以让窗体非矩形显示,也可以让所有的控件非矩形显示,因为都有Paint事件
private void Form1_Paint(object sender, PaintEventArgs e)
...{
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);
}

本文介绍了一种在Windows窗体应用程序中实现非矩形窗体的方法。通过重写窗体的Paint事件并使用GraphicsPath定义窗体边界,可以创建椭圆形等不规则形状的窗体。这种方法同样适用于窗体内所有控件的非矩形显示。
743

被折叠的 条评论
为什么被折叠?



