Adding the same Panel to multiple TabPages

Posted by BDotA on Stack Overflow See other posts from Stack Overflow or by BDotA
Published on 2010-06-01T21:13:00Z Indexed on 2010/06/01 21:13 UTC
Read the original article Hit count: 213

Filed under:
|
|

In my previous question I could add a design time panel to a tab page at run time and my code looks like this and it works Ok.

        tabControl1.SuspendLayout();
        tabControl1.TabPages[0].Controls.Add(panel1);
        tabControl1.ResumeLayout();

but now I need to do something like this:

    tabControl1.SuspendLayout();
    tabControl1.TabPages[0].Controls.Add(panel1);
    tabControl1.TabPages[1].Controls.Add(panel1);
    tabControl1.TabPages[2].Controls.Add(panel1);
    tabControl1.ResumeLayout();

which just at run-time I can know how many of these Tabpages I will need. but now for testing I am assuming I will have three tabPages

the Problem is that the panel only gets added to the Last tabPage, How can I fix this? I want it get added to all of the tab pages Thanks.

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms