Hide defalut Event in a Superclass

How can I hide some default Events of a superclass?

I created a super class of DesktopHTMLViewer.
If I put the class in the form, it automatically displays all the default events of DesktopHtmlViewer.
While I would only like to be able to use the events defined by me, not default.

Is it possible?

In your class definition, add empty handlers for any events you don’t want to be visible to a subclass or on the form.

What’s easy? Thanks!

And can we hide standard methods and properties?
I need to display only the methods and properties created by me, not the standard ones coming from the superclass.

No, methods and events operate very differently.

What about placing the control you’re trying to hide inside a DesktopContainer?

As long as the control’s scope is private, it (or its properties and methods) shouldn’t be accessible from outside the container.

Or maybe you’ve already done that… and you’re trying to hide the container property and methods?

FWIW, Methods can be “hidden” if you override them in your subclass and make them private.

Properties are trickier. You could do the same as above (what’s called shadowing) but you then have to be very careful about which property you’re actually using, because there’s actually two. It can be done, but as I said, it’s tricky, not to mention error-prone.

Beware though… if you do this, you may find yourself face-to-face with your 20-year older self, back from the future, coming to kill you.

6 Likes