如何使表单的背景透明?在 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.
这篇关于使表单的背景透明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!