Adding a Design time Panel to a TabPage at run time
I wish to have a Panel with the controls on it at design time but I want to add this panel to a desired tabPage of my TabControl at run time.
I wrote something lik开发者_如何学Ce this, did not work : the panel does not show up in the tab page. please help me.
panel2.Parent = tabGuy.TabPages[0];
tabGuy.SuspendLayout();
tabGuy.TabPages[0].Controls.Add(panel2);
tabGuy.ResumeLayout();
panel2.Show();
You probably need to set the coordinates of the Panel as well, or (better) panel2.Dock = DockStyle.Fill;
And you don't have to set the .Parent or call the .Show()
精彩评论