如何在c#中复制tabPage? [英] How can I duplicate tabPage in c#?
本文介绍了如何在c#中复制tabPage?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何复制我的TabControl里面的tabPage?
我试过:
//我的TabControl:tc
//我的标签ID:0
TabPage newPage = new TabPage
foreach(tc.TabPages [0] .Controls中的控制控制)
{
newPage.Controls.Add(control);
}
tc.TabPages.Add(newPage);
但不工作。
提前感谢。
对于我们来说,这是非常感谢的。
解决方案那些有同样问题的人,这是我做的:
我创建了一个UserControl(非常感谢@SLaks和@Brian的提示),将我的TabControl中的所有对象复制到我的新UserControl,并使用以下代码创建动态标签页:
for x = 0; x <3; x ++)
{
UserControl1 uc = new UserControl1();
TabPage tp = new TabPage();
tp.Controls.Add(uc);
this.TabControl1.TabPages.Add(tp);
}
How can I duplicate a "tabPage" inside of my TabControl?
I tried this:
//My TabControl: tc
//My Tab ID: 0
TabPage newPage = new TabPage();
foreach (Control control in tc.TabPages[0].Controls)
{
newPage.Controls.Add(control);
}
tc.TabPages.Add(newPage);
but isn't works..
Thanks in advance.
解决方案
I got it!
For those who has the same kind of problem, Here is what I’ve done:
I had created a UserControl (thanks a lot for @SLaks and @Brian for your tip), copied all objects from my TabControl to my new UserControl and used the follow code to create a dynamic tabs:
for (int x = 0; x < 3; x++)
{
UserControl1 uc = new UserControl1();
TabPage tp = new TabPage();
tp.Controls.Add(uc);
this.TabControl1.TabPages.Add(tp);
}
这篇关于如何在c#中复制tabPage?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文