Make a form#39;s background transparent(使表单的背景透明)
问题描述
如何使表单的背景透明?在 C# 中可以吗?
How I make a background transparent on my form? Is it possible in C#?
提前致谢!
推荐答案
您可以将表单的 BackColor
设置为不常见的颜色(例如 Color.Magenta
)然后将表单的 TransparencyKey
属性设置为相同的颜色.然后,将 FormBorderStyle
设置为 None
.
You can set the BackColor
of your form to an uncommon color (say Color.Magenta
) then set the form's TransparencyKey
property to the same color. Then, set the FormBorderStyle
to None
.
当然,这只是快速简便的解决方案.控件的边缘很难看,您必须不断更改您添加的新控件的背景颜色(如果它们是按钮或类似的东西)以及一大堆其他问题.
Of course, that's just the quick and easy solution. The edges of controls are ugly, you have to keep changing the background color of new controls you add (if they're Buttons or something like that) and a whole host of other problems.
这真的取决于你想要实现什么.它是什么?如果你想做一个小部件之类的东西,有更好的方法.如果您需要圆角或自定义背景,还有更好的方法.因此,如果 TransparencyKey
不是您的想法,请提供更多信息.
It really depends what you want to achieve. What is it? If you want to make a widget sort of thing, there are much better ways. If you need rounded corners or a custom background, there are much better ways. So please provide some more information if TransparencyKey
isn't quite what you had in mind.
这篇关于使表单的背景透明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使表单的背景透明


- WebMatrix WebSecurity PasswordSalt 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 输入按键事件处理程序 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01