Parameterized constructor in Visual Designer

Posted by alextrs82 on 27-May-2014 18:14

Hello,

Is there any way I can use parameterized constructor in Visual Designer. If not, what other options (so then we can still use Visual Designer to move control) we have?

We use 10.2B SP08

Regards,

Aliaks

All Replies

Posted by Matt Baker on 27-May-2014 20:06

You cannot.  PDS (OEA in 10.2b) has no way of knowing what values to pass to that constructor, and it has no way to construct objects of those values either.  In addition, it doesn't actually run your code.  It uses code parsing and reflection to run the steps defined in the initializecomponent method at design time.

You need to provide a no argument constructor.

Posted by Mike Fechner on 27-May-2014 23:08

I assume, you need the constructor with parameters for a UserControl contained in a Form you are designing.

You need to use PUBLIC properties instead. Those show up in the property sheet so that you can provide values.

If you need to set multiple properties before you react on then, implement this interface:


And put your code into the EndInit method. The Visual Designer will generate code that calls this method after the properties are assigned.


Gesendet von Surface Pro

Von: alextrs82
Gesendet: ‎Mittwoch‎, ‎28‎. ‎Mai‎ ‎2014 ‎01‎:‎15
An: TU.OE.Architecture@community.progress.com

Thread created by alextrs82

Hello,

Is there any way I can use parameterized constructor in Visual Designer. If not, what other options (so then we can still use Visual Designer to move control) we have?

We use 10.2B SP08

Regards,

Aliaks

Stop receiving emails on this subject.

Flag this post as spam/abuse.

Posted by alextrs82 on 28-May-2014 07:59

ISupportInitialize is exactly what I was looking for. Thank you, Mike.

This thread is closed