問題描述
如何使表單的背景透明?在 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模板網!