开发者

Adding the same Panel to multiple TabPages

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

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 onl开发者_C百科y gets added to the Last tabPage, How can I fix this? I want it get added to all of the tab pages Thanks.


You can't. A control can have only one parent at a time. Luckily, only one tab page is visible at a time, so I guess you could move the panel between the pages as they are displayed? On the other hand, if the panel is to be located in the same place for all pages, perhaps it should not be placed inside the tab control, but rather on top of it?

0

精彩评论

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

关注公众号