how to customise the InitializeComponent

Posted by jmls on 30-May-2011 14:55

I need to be able to add some custom code to the InitializeComponent method.

What is the best way of doing this ?

I am wanting to add some code to this method , and not lose it if I go into the designer and move a field around.

All Replies

Posted by Admin on 30-May-2011 15:07

I need to be able to add some custom code to the InitializeComponent method.

 

Can you be a bit more precise about what kind of custom code?

What is the best way of doing this ?

Be prepared for disappointment. The Microsoft .NET Visual Designer Framework and the Control vendor control most of which properties get serialized to source code. The easiest way to customize the code generation is using customized .NET Controls (Visual Studio). A lot of things are possible from the ABL as well (check out the ICustomTypeDescriptor Interface) - but that requires using inherited Controls as well.

Maybe creating an Extender Provides (like the UltraDockManager) can help you.

But it all requires understanding your demands. In case you didn't have the plan yet, book your flight to PUG Challenge Americas and don't miss my presentation about Customizing the OpenEdge Architect Visual Designer.

Posted by Peter Judge on 31-May-2011 08:04

I need to be able to add some custom code to the InitializeComponent method.

Can you be a bit more precise about what kind of custom code?

My understanding is that the InitialiseComponent method gets blown away *every time*. So I'd not add anything in there that you want to survive the form being opened in the designer.

Mike's Extender-Provider approach is a good one - although for now, you'll need to write it in C# or some other pure .NET language since it uses annotations to do its thing.

-- peter

Posted by Admin on 31-May-2011 08:32

Mike's Extender-Provider approach is a good one - although for now, you'll need to write it in C# or some other pure .NET language since it uses annotations to do its thing.

 

Haven't used it for the Extender Provider yet, but the Annotations are not required when you implement ICustomTypeProvider.

Posted by rbf on 31-May-2011 08:35

pjudge wrote:


My understanding is that the InitialiseComponent method gets blown away *every time*. So I'd not add anything in there that you want to survive the form being opened in the designer.


Exactly, even between service packs.

Our rule is *never* to touch any *file* that is generated and maintained by the VD.

That file is our ' View' .

Then we create an ABL class that inherits from the View where we add logic (this is our 'Controller').

Here you can extend InitializeComponent in a safe way.

It is our poor man's MVC implementation (we have a Model as well) but considering the tools Progress gives us it works well and allows us to keep the visual designer generated code separate from the developer code. the code is much easier to maintain that way.

HTH

-peter

This thread is closed