日期:2014-05-19  浏览次数:20922 次

窗体继承问题
我想设置一个父窗体,其它窗体继承这一窗体,这样用来设置窗体颜色的个性化,但窗体上的其它控件则挡住了一部分,这样看起来很难看,把控件设置成透明色太麻烦,也不好,请问有没有一个很好的解决办法

------解决方案--------------------
public static void SetSkin(Form form)里面可以这么写
foreach (object control in form.Controls)
{
if (control is TabControl)
{
int sums = ((TabControl)control).TabPages.Count;
for (int i = 0; i < sums; ++i)
{
((TabControl)control).TabPages[i].BackColor = skin.BackColors;
}
}
if (control is Button)
{
((Button)control).BackColor = skin.ButtonColor;
((Button)control).ForeColor = skin.ButtonFontColor;
}
if (control is CustomControl.ButtonCustom)
{
((CustomControl.ButtonCustom)control).BackColor = skin.ButtonColor;
((CustomControl.ButtonCustom)control).ForeColor = skin.ButtonFontColor;
}
if (control is CustomControl.CustomButtonAngle)
{
((CustomControl.CustomButtonAngle)control).BackColor = skin.ButtonColor;
((CustomControl.CustomButtonAngle)control).ForeColor = skin.ButtonFontColor;
}
if (control is CustomControl.CustomControlForm)
{
((CustomControl.CustomControlForm)control).BackColor = skin.BackColors;
}
if (control is Panel)
{
((Panel)control).BackColor = skin.BackColors;
}
if (control is TextBox)
{
((TextBox)control).ForeColor = skin.TextFontColor;
((TextBox)control).BackColor = skin.TextColor;
}
if (control is ComboBox)
{
((ComboBox)control).ForeColor = skin.TextFontColor;
((ComboBox)control).BackColor = skin.TextColor;
}
if (control is Label)
{
((Label)control).BackColor = skin.BackColors;
((Label)control).ForeColor = skin.FontColor;
}
if (control is RadioButton)
{
((RadioButton)control).ForeColor = skin.RadioButtonBackColor;
((RadioButton)control).BackColor = skin.BackColors;
}
}