在C#windows应用程序中,我的文本框中的透明度使其好像不在那里

时间:2012-07-17 05:27:09

标签: c# transparency richtextbox

嘿伙计我使用此代码为我的表单启用透明度:

private void TypingFreak_Load(object sender, EventArgs e)
{
   this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
   this.TransparencyKey = Color.FromKnownColor(KnownColor.Control);
   this.Update();
}

但是,好像不在那里,所以如果我在桌面上运行它,我可以看到图标并与它们做出反应(我无法写入文本框)

在我的表单中,我有2个丰富的文本框,我希望它们对我的表单背景的背景颜色透明。 任何想法如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

TransparencyKey使表单的行为就像在具有该颜色的地方不存在一样。在您的情况下,它是所有内容控件(如TextBox,ListBox等)的背景颜色,因此几乎整个表单都是不可见的。或者,如果你的表格有不同的颜色,那么你可以在你控制这些控件的地方找到洞。

您需要通过设置透明背景颜色使控件本身透明,但并非所有控件都支持此功能。实际上,RichTextBox(和TextBox)不会:

enter image description here

导致

enter image description here