如何在C#中创建非矩形窗口形式? [英] How to create a non rectangular window form in c#?

查看:103
本文介绍了如何在C#中创建非矩形窗口形式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以在c#或.net中创建非矩形窗口形式,例如圆形或椭圆形?

我看到了这些独特的窗户形状,它们在我见过的几个安装中看起来都非常整洁。

Is there any way of creating a non rectangular window form, such as circle or ellipse, in c# or .net?
I saw these unique windows form shapes and they look really neat in several installations I've seen.

此外,使用中是否有任何缺点

Also, is there any disadvantage in using this kind of design for non standard forms, such as sustainability, crashes, etc.?

推荐答案

表单具有Region属性,您可以将其用于非标准表单,例如可持续性,崩溃等。在此处分配您创建的任何形状。
例如,要创建椭圆形,可以在 Form1_Load()形式的方法中使用以下代码:

Form has Region property and you can assign there any shape that you create. For example to create oval form you can use this code in Form1_Load() method of form:

 var path = new GraphicsPath();

 path.AddEllipse(0, 0, Width, Height);
 Region = new Region(path);

风险是当您创建非矩形表单并关闭时,最小化按钮会按区域切断那么某些最终用户可能会在关闭您的应用程序时遇到问题。

The risk is that when you create non-rectangular form and close, minimalize buttons are cut off by region then some of end-users could have problems with closing your application.

这篇关于如何在C#中创建非矩形窗口形式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆