[英]Foreach control in tabpage
所以我有一个背景的这个表格。 问题是我有一个巨大的下降,表现明智。 所以有人告诉我只需使用一个图片框并使用“设置为后退”来获得相同的效果。
现在的问题是我的控件的背景不再透明,但与表单背景相同。
所以有人告诉我使用这段代码:
control.Parent = pictureboxBackground;
control.BackColor = Color.Transparent;
但是现在我必须为我的所有20个控件编写这两行代码。
所以我尝试使用以下foreach语句:
foreach (Control but in tabPage2.Controls)
{
but.Parent = pictureBox1;
but.BackColor = Color.Transparent;
}
但现在我的控件背面只有一半是透明的。
例如:
Label1是透明的
label2不是
button1不是
button2是透明的
我究竟做错了什么?
尝试这个:
foreach (Control but in tabPage2.Controls)
{
but.Parent = pictureBox1;
but.BackColor = Color.Transparent;
}
Application.DoEvents();
要么
foreach (Control but in tabPage2.Controls)
{
but.Parent = pictureBox1;
but.BackColor = Color.Transparent;
but.Invalidate();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.