日期:2014-05-18  浏览次数:20876 次

tabControl看得见,tabPage看不见,请高手解决
创建一个窗口,窗口里放个tabControl,tabControl里放个tabPage,tabControl看见了,tabPage看不见,tabPage设置了背景色,颜色闪了一下,没了。
window   win   =   new   window();
win.SuspendLayout();
win.MdiParent   =   this;
TabControl   tabControl   =   new   System.Windows.Forms.TabControl();
tabControl.SuspendLayout();
win.Controls.Add(tabControl);
tabControl.Dock   =   System.Windows.Forms.DockStyle.Fill;
TabPage   tabPage   =   new   TabPage();
tabPage.SuspendLayout();
tabControl.Controls.Add(tabPage);
tabPage.Text   =   "123 ";
tabPage.BackColor   =   System.Drawing.Color.Red;
for   (int   j   =   0;   j   <   win.Controls.Count;   j++)
{
        win.Controls[j].ResumeLayout(false);
}
win.ResumeLayout();
win.Show();

------解决方案--------------------
不知道你程序里面的window是什么意思,我把window换成Form,一切正常啊!
------解决方案--------------------
TabControl.TabPages.Add