Hide a componet?

D

David Veeneman

Is it possible to hide a component that is used as a base class for other
components?

I have two components that perform the same job. Their only difference is
that one works with objects, and the other works with data rows. So, I
derived both from a common base component and used a GoF Template Method
pattern to encapsulate the parts that differ in the derived components.

Here's my problem: I can't make the base component abstract, due to visual
inheritance limitations. (.NET needs to instantiate the base component to
instantiate the derived components.) But that means a developer using my
package could instantiate the base component, which I obviously don't want.

So, is there a simple way to hide the base component from a developer using
the controls, so that only the derived controls are exposed? Thanks.
 
N

Nicholas Paldino [.NET/C# MVP]

David,

You can always set the components visiblity to "private".
 
D

David Veeneman

I did discover that I could make the base component abstract, at the cost of
sacrificing Designer support for the derived components. However, since the
components don't have visual elements, and they don't contain other
components, it's no real sacrifice.
 
N

Nicholas Paldino [.NET/C# MVP]

Barry,

You can't, but if the controls or members of your public component are
private, then derived classes can't access them.
 

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