Click here to Skip to main content
15,883,940 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created an user Control. Working perfectly. It is having 'BoderStyle' property.
I do not want this property. User Controls border should not be changed. I want to remove this property altogether. I found some help from Code Project itself, by Implementing ICustomTypeDescriptor in the user control. It removed the border style from Property Grid. But in run time it is still there. How do I remove this property in run time also. Any body can help.

What I have tried:

Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
Me.MyControl.BorderStyle = BorderStyle.Fixed3D

End Sub
Posted
Updated 15-Jan-21 8:06am

1 solution

Have a look here: Hiding Inherited Properties and Tasks in Derived Classes[^]
This is C# based, but it's the same process to hide properties in VB - just the attribute syntax is different:
VB
<Browsable(False), EditorBrowsable(EditorBrowsableState.Never)>
Public Overloads Property AutoScroll As Boolean
 
Share this answer
 
v2
Comments
Richard Deeming 18-Jan-21 6:33am    
OriginalGriff 18-Jan-21 7:12am    
No, you are replacing it with a property of the same name that is unrelated to the existing one.
Think "new" in C#:
[Browsable(false),
EditorBrowsable(EditorBrowsableState.Never)]
public new bool AutoScroll { get; set; }
Richard Deeming 18-Jan-21 8:15am    
But the AutoScroll property is virtual; would it not work if you override the property and set the new attributes on that?
OriginalGriff 18-Jan-21 8:26am    
Attributes are inherited, yes:
https://doc.postsharp.net/aspect-inheritance
But the idea here is to hide the property, not allow it to be called via a base class instance declaration.
Using new breaks the inheritance chain so a base class instance can't call the "hidden" method in the derived class.
Member 11700078 18-Jan-21 10:30am    
Thanks a lot this is working fine.

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