Click here to Skip to main content
15,891,902 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more: , +
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 (vb.net) 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
Comments
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.
[no name] 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

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.

http://en.wikipedia.org/wiki/Object-oriented_programming[^],
http://en.wikipedia.org/wiki/Dynamic_dispatch[^].

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.

—SA
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900