By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,458 Members | 1,435 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,458 IT Pros & Developers. It's quick & easy.

Add properties to a control at Run-Time?

P: n/a
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
Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
You can create a new class inherited from the original class and add your
new properties.

Tiansong Pu

"Özden Irmak" <ozdenirmak(at)isnet.net.tr> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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

Nov 16 '05 #2

P: n/a
J L
Hi Ozden,
Check out this link:

http://msdn.microsoft.com/library/de...et04082003.asp

Shows the use of Extender Providers to add properties, etc. to
textboxes but could work with any control. Well written article and
the download shows the source code. I used it to develop my own text
validator using much of Mr. Hollis' ideas but changing the overall
behavior to suit my needs.

John

On Wed, 9 Mar 2005 10:15:36 +0200, "Özden Irmak"
<ozdenirmak(at)isnet.net.tr> wrote:
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


Nov 16 '05 #3

P: n/a
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/miscct...g_property.asp

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

Thanks again,

Özden

"J L" <jo**@marymonte.com> wrote in message
news:bh********************************@4ax.com...
Hi Ozden,
Check out this link:

http://msdn.microsoft.com/library/de...et04082003.asp

Shows the use of Extender Providers to add properties, etc. to
textboxes but could work with any control. Well written article and
the download shows the source code. I used it to develop my own text
validator using much of Mr. Hollis' ideas but changing the overall
behavior to suit my needs.

John

On Wed, 9 Mar 2005 10:15:36 +0200, "Özden Irmak"
<ozdenirmak(at)isnet.net.tr> wrote:
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

Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.