Put it in a loop, including the new statement but varing the position.
You could also clone the object, maybe with performance penalties ... Sorry but don't know Vb.net, I will give you the c# code hoping it will be similar. I think this it is not the best solution for your case (a loop will do the trick), but maybe it will be for someone with a similar but more generic problem.
CheckBox CB2 = (CheckBox)CloneObject(CheckBox1);
//change the location here... Form1.Controls.Add(checkBoxCB2 )
private object CloneObject(object o)
{
Type t = o.GetType();
PropertyInfo[] properties = t.GetProperties();
Object p = t.InvokeMember("", System.Reflection.BindingFlags.CreateInstance, null, o, null);
foreach(PropertyInfo pi in properties)
{
if(pi.CanWrite)
{
pi.SetValue(p, pi.GetValue(o, null), null);
}
}
return p;
}
Jonathan
2010-09-01 18:06:50