How to call the Constructor with Parameter using IDesignerHost.CreateComponent

  • Thread starter Thread starter Jerry
  • Start date Start date
J

Jerry

Hi,

As you know, In design-time of .net framework, all controls created
by IDesignerHost.CreateComponent. But my control's constructor has some
parameter, how to call it?

Jerry
 
Hi Jerry

Maybe i'm wrong, but i think that you shold have "default"
constructor for every control/component that you want to place
from designer.
Visual studio doesn't allow you to place control without
default contructor.

To call parametrized constructor from "default" use:

public MyControl()
: this(param1, param2, ...)
{
// todo
}

Regards

Marcin
 
Back
Top