如何在标签控制广告中为标签栏页面创建克隆
本文关键字:标签栏 创建 标签 控制 | 更新日期: 2023-09-27 18:36:36
如何在tabcontroladv中为标签栏页面创建克隆?
我已经创建了克隆,但更改父控件会反映在克隆的控件中。我需要父控件和克隆控件都应该分开。我使用了以下代码:
private void button1_Click(object sender, EventArgs e)
{
TabPage newPage = new TabPage();
foreach (Control c in tabControl1.TabPages[0].Controls)
{
Control cNew = (Control)Activator.CreateInstance(c.GetType());
PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(c);
foreach (PropertyDescriptor entry in pdc)
{
object val = entry.GetValue(c);
entry.SetValue(cNew, val);
}
newPage.Controls.Add(cNew);
}
tabControl1.TabPages.Add(newPage);
}
创建克隆后,父控件中的更改将反映在克隆的 cotrol 中。
我可以有一个示例吗? 如何创建克隆。 父项中的更改不应反映到克隆的控件中。
是的,可以在 TabBarPage 中克隆控件,因为父 TabBarPage 中的更改不应反映到克隆的 TabBarPage 中。
标签栏页面新页面;
// To Copy
newPage = new TabBarPage();
foreach (Control c in this.tabBarSplitterControl1.ActivePage.Controls)
{
Control cNew = (Control)Activator.CreateInstance(c.GetType());
PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(c);
foreach (PropertyDescriptor entry in pdc)
{
object val = entry.GetValue(c);
entry.SetValue(cNew, val);
}
newPage.Controls.Add(cNew);
}
newPage.Text = "New Tab";
// To Paste
this.tabBarSplitterControl1.TabBarPages.Add(newPage);
示例链接:http://www.syncfusion.com/downloads/support/directtrac/general/Cloning964503659.zip