表单上的透明背景 [英] Transparent background on form
问题描述
我尝试了很多方法来在我的表单上设置透明背景.透明键确实有效,但是当您放置不透明的图像时会出现问题.我试图覆盖 OnPaintBackground
,它只删除了我的背景图像.我尝试了 SetStyle
方法.
I have tried many ways to have a transparent background on my form. Transparency key does work, but problems arise when you put images that have opacity. I tried to override OnPaintBackground
which only removed my background image. And I tried the SetStyle
method.
推荐答案
假设您使用的是 windows 窗体,请尝试:
Assuming you are using windows forms, try:
this.TransparencyKey = Color.Red;
this.BackColor = Color.Red;
当表单上的颜色与您的透明度键相同时,它将是透明的.另一方面,由于红色仅用于透明度,您将无法使用它.
when you have a color on the form which is the same as your transparency key, then it will be transparent. on the other hand, by that the red color is assigned for transparency only, you won't be able to use it.
(和this
指的是表单)
这篇关于表单上的透明背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!