在面板中添加透明控件 [英] Add control transparent in a Panel
本文介绍了在面板中添加透明控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要您的帮助,
我想知道如何在面板内添加透明的表单.
像
mypanel.Control.Add(myForm);
但是当我尝试这样做时,我的表单就失去了透明度.
我该怎么做?
I need your help,
I want to know how add a form transparent inside a panel.
something like
mypanel.Control.Add(myForm);
but when I try to do this my form lose the transparent.
How I can do it?
推荐答案
我假设您谈论的是System.Windows.Forms
.简短的答案是:切换到WPF .在某些问题上,Forms
带来了透明度方面的严重问题,并且在存在这些问题的情况下,它们不会变得更加容易.控制级别的透明度就是这种情况.
或者,您可以将Forms
与您自己的渲染一起使用,而不是在控件级别上使用,而是在一个控件内直接使用System.Drawing.Graphics
在事件Paint
的处理程序中或通过覆盖虚方法OnPaint
.在这个级别上,透明度根本不是问题.请同时参阅我过去的答案:
在mdi子表单之间画线 [在面板上捕获图形 [ Paint是一种哪种好玩的方法? (DataGridViewImageCell.Paint(...)) [
I assume you talk aboutSystem.Windows.Forms
. Short answer is: switch to WPF. In certain problems,Forms
presents serious problems with transparency, and, where those problems exist, they are not going to become easier. Transparency at the level of control is the case.
Alternatively, you can useForms
with your own rendering not at the level of controls, but within one control, usingSystem.Drawing.Graphics
directly, in the handler of the eventPaint
or by overriding the virtual methodOnPaint
. At this level, transparency is not a problem at all. Please see also my past answers:
Drawing Lines between mdi child forms[^],
capture the drawing on a panel[^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^].
—SA
这篇关于在面板中添加透明控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文