i have:
object[] obj = new object[button1, label1]; //
object parent; // some Panel
i need
for (int i = 0; i < obj.Length; i++)
obj[i].Parent = parent;
How to get it?
i have:
object[] obj = new object[button1, label1]; //
object parent; // some Panel
i need
for (int i = 0; i < obj.Length; i++)
obj[i].Parent = parent;
How to get it?
var controls = new Control[] { button1, label1 };
Control parent = ...;
foreach (Control control in controls)
{
control.Parent = parent;
}
Normal .NET parent/child relationships are created like this:
parent.Controls.Add(child);
object[] obj = new object[] { button1, label1 }; // create array of objects
object parent; // some Panel
for (int i = 0; i < obj.Length; i++)
{
((Control)obj[i]).Parent = parent;
}
u just using Controls? if this define ur array as bellow:
Control[] controls = new Control{button1, lable};
for (int i = 0; i < controls.Length; i++)
controls[i].Parent = parent;