Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / August 2006

Tip: Looking for answers? Try searching our database.

Hide a componet?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Veeneman - 19 Aug 2006 16:41 GMT
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.

Signature

David Veeneman
Foresight Systems

Nicholas Paldino [.NET/C# MVP] - 19 Aug 2006 17:18 GMT
David,

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

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> Is it possible to hide a component that is used as a base class for other
> components?
[quoted text clipped - 12 lines]
> 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.
Barry Kelly - 19 Aug 2006 18:27 GMT
>     You can always set the components visiblity to "private".

I suspect you can't make public descendants of private components.

-- Barry

Signature

http://barrkel.blogspot.com/

Nicholas Paldino [.NET/C# MVP] - 21 Aug 2006 02:25 GMT
Barry,

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

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

>>     You can always set the components visiblity to "private".
>
> I suspect you can't make public descendants of private components.
>
> -- Barry
David Veeneman - 20 Aug 2006 02:21 GMT
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.

Signature

David Veeneman
Foresight Systems


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.