Reputation: 1896
I want to perform
this.Controls.Add(MyObject)
in the class definition of MyObject like
public MyClass(container/*?*/ con,Point L)
{
con.Controls.Add(this);
}
can I do something like this? thanks.
Upvotes: 3
Views: 331
Reputation: 203828
Control
will work just fine.
public void method(Control container)
{
container.Controls.Add(this);
}
If you pass in a Control
that can't actually have children (say, TextBox
) it will either do nothing or throw an exception at runtime.
Upvotes: 1