Copy TabControl Tab


Answer :

EDIT


I have rewritten my solution to use reflection.


using System.Reflection;

// your TabControl will be defined in your designer
TabControl tc;
// as will your original TabPage
TabPage tpOld = tc.SelectedTab;

TabPage tpNew = new TabPage();
foreach(Control c in tpOld.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);
}

// add control to new TabPage
tpNew.Controls.Add(cNew);
}

tc.TabPages.Add(tpNew);

Some information can be found here.
http://www.codeproject.com/Articles/12976/How-to-Clone-Serialize-Copy-Paste-a-Windows-Forms



Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable