Click here to Skip to main content
13,044,935 members (44,404 online)
Rate this:
Please Sign up or sign in to vote.
Dear all
I am creating a numerical text box control and named it NumTextbox, but when I create an object from it, I saw the UserControl events in the object with my custom events, so I want to prevent the object to inherits the UserControl events, methods and properties, I want it to inherits my own only.

I don't want to use NotInheritable ( or Sealed (C#) key words, because if you have class A, and class B that inherited from A but it is NotInderitable, that means no class can be inherited form B.
That is not what I want, I want to prevent the developer to see the UserControl events, properties or methods when he is in view code editor (the events combobox in code editor) if he add an object from that ActiveX control on the form. I want to display my own events only, not the UserControl events.
Did you got my idea?
Can anybody help me please?
Posted 3-Dec-11 9:47am
Philippe Mori 3-Dec-11 17:44pm
I think it is mainly a waste of time to do that. What the problem with inheriting a few extra events. If you uses standard controls, you get some events, properties and methods you might never use but it does not matters much.

By the way, I think it is possible to hide them but the user could probably get to them by passing through the base class first.
CDP1802 3-Dec-11 19:30pm
And, if some functionality of the base class somehow is in the way, the right way to go would be to overload them with a new implementation that does work.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You need to go back the fundamentals of OOP and make sure you understand them and are comfortable to use them on practice, before returning to UI development or any other advanced issues. At the moment, you have no idea of how OOP works.

Every single member of the base class is inherited by the derived class. Nothing can prevent it, ever; and nobody wants to prevent it, ever. The class can only be extended, but some methods can be virtual and overridden, see the second link below.

It has nothing to do with NotInheritable and sealed. These keywords prevent inheriting from the class as a while thing. Derived classes are not possible at all in this case.[^],[^].

As to your problem, it simply does not exist. The only problem is that you want something you should not want. You did not provide any rational reasons.


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 4 Dec 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100