At designtime, how can I hide a base class property in my derived control from the user

Platform: WinForms| Category: UI

Set the Browsable attribute on the new property that hides the existing one. Here is a code snippet that hides the WordWrap property in the derived TextBox.

[C#]
public class MyTextBox : TextBox
{
	[Browsable(false)]
	public new bool WordWrap
	{
		get{ return false;} //always false
		set{}
	}
}

[VB.NET]
Public Class MyTextBox
	Inherits TextBox
    
	  _
	Public Shadows Property WordWrap() As Boolean
		Get
			Return False ’always false
		End Get
		Set ’empty
		End Set
	End Property
End Class ’MyTextBox 

Share with