Why can't I hide inherited events the same way I can hide properties?

I have a usercontrol that inherits from the UserControl class. There are a bunch of items that I want to hide from those who use the class.

I can hide the properties just fine ...

public partial class userControls_MyControl : System.Web.UI.UserControl {

    private new bool EnableTheming {get; set;}
}

This effectively removes it from display in the IntelliSense editor.

However, when I try to do the same with events, they still appear ...

public partial class userControls_MyControl : System.Web.UI.UserControl {

    private new EventHandler AbortTransaction { get; set; }
    private new EventHandler OnAbortTransaction {get;set;}
}

Is there any way to hide the event? Why is this not working?

Thanks in advance.

+3
source share
2 answers

You are trying to hide a property that does not exist. You need to use the event syntax to do this: -

 private new event EventHandler AbortTransaction;

, EditorBrowserable , . , AbortTransaction , .

+2

Source: https://habr.com/ru/post/1716235/


All Articles