Easier way to expose properties?

L

ljh

I am using some 3rd party controls to create my own control.

I want to "pass up" many (but not all) of the properties of the 3rd party
controls that I am using to make my control, so that the end user can
customize as much or as little as they wish. But, there are HUNDREDS of
properties (of the combined controls).

Is there an easy way to expose the properties of the controls that I am
using to make my control adn still be able to block the very few properties
that (if set wrong) may make my control act up?
 
T

Tasos Vogiatzoglou

The first solution (politically correct) would be to provide accessors
to all the interested properties. The second solution (also politcially
correct) would be to subclass the original component and hide the
properties you don't want.

There is also a third solution, but it's a bit hackish ... By using
reflection you can create a method SetProperty(string name, object
value) and set the values of the properties. There you can check for
properties you don't want to change.

Regards,
Tasos
 
C

cody

what is wrong with

myComponent.MySubComponent.Property = newValue;

This way you do not need to program the properties again.
There also might be tools/codegenerators which might be able to automatize
the generation of properties for you. If not, you can easily generate a code
generator by yourself using reflection.
 

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