views:

61

answers:

1

Hi,

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  A: 

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

Henk Holterman
DockStyle did the Trick. Thank a lot.
BDotA