First, thank you for taking the time to read my question.
I have spent a good amount of time on this issue with no success. I have created a Custom TextBox which inherits from TextBox. The Custom TextBox provides a more advanced suggestion drop-down menu with better filtering. The custom TextBox works beautifully, but I would like to hide the properties related to the original suggestion menu from the Properties Window in Visual Studio:
- AutoCompleteCustomSource
- AutoCompleteMode
- AutoCompleteSource
The code I've developed to try and hide these properties is:
[ReadOnly(true)]
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This property is obsolete.", true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
new private AutoCompleteStringCollection AutoCompleteCustomSource { get; set; }
[ReadOnly(true)]
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This property is obsolete.", true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
new private AutoCompleteMode AutoCompleteMode { get; set; }
[ReadOnly(true)]
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This property is obsolete.", true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
new private AutoCompleteSource AutoCompleteSource { get; set; }
The sources I've used are:
- Making the Visual Studio designer ignore a public property
- Hiding unwanted properties in custom controls
The properties are still being displayed. Please provide a working example or a reference to one.
Thank you again for lending me your time.
In your actual code, do you really use the
newkeyword to allow your declared properties to hide base class properties?If so, then it seems most likely to me that the properties being shown in the VS Designer are not your own, but rather the base class properties.
Note that this only happens when you also change the accessibility of the property (e.g. where the base class property is
publicbut your own derived class property isprivate).Just one more example of why it's almost always wrong to hide inherited members.