开发者

Adding a Design time Panel to a TabPage at run time

开发者 https://www.devze.com 2023-01-01 13:58 出处:网络
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 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()

0

精彩评论

暂无评论...
验证码 换一张
取 消