Add properties to a control at Run-Time?

Ö

Özden Irmak

Hi,

I've developed a couple of Windows Forms controls. To extend their
flexibility, in run-time, I should be able to define/add new properties for
those controls.

I know that Reflection.Emit namespace is for that purpose. I have searched
for possible examples about this and only found the ones which create the
assembly, module and properties (As a whole) from scratch. But I want to add
new properties to an existing Class?

Does anybody have any example about this? I need examples such as how to
retrieve mehtodbuilder from an exsiting class, etc. to add new properties?

Thanks in advance,

Özden
 
T

Tiansong Pu

You can create a new class inherited from the original class and add your
new properties.

Tiansong Pu
 
Ö

Özden Irmak

Hi,

Thank you both for taking time and trying to help me...

I know I can extend a class by deriving from it and add my properties and I
also know Extender Providers to add properties to controls. But both of
these solutions are again static, I mean I hardcode which properties will be
added to my standart control. My problem was creating properties on the fly,
this means when I instance an object in my applicaiton, I add properties
into it and it becomes a modified class.

Anyway, I could find the solution at here :

http://www.codeproject.com/cs/miscctrl/bending_property.asp

I hope it will be usefull for anybody in a situation like me...

Thanks again,

Özden
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top