Adding a Design time Panel to a TabPage at run time

本秂侑毒 提交于 2019-12-10 23:35:18

问题


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 like 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();

回答1:


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()



来源:https://stackoverflow.com/questions/2950321/adding-a-design-time-panel-to-a-tabpage-at-run-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!