【发布时间】:2015-01-07 05:23:21
【问题描述】:
如何在 tabcontroladv 中为 tabbarpage 创建一个克隆?
我已经创建了克隆,但是更改父控件会反映在克隆控件中。我需要将父控件和克隆控件分开。 我使用了以下代码:
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);
}
创建克隆后,父控件中的更改会反映在克隆的控制中。
我可以为此提供样品吗?如何创建克隆。父级的更改不应反映到克隆控件。
【问题讨论】:
-
这个问题可以用普通的 WinForm TabControl/TabPage 重现吗?
标签: c# winforms syncfusion