Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

How do I hide a base class property in my derived control from the user at design-time?

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 CustomTextBox : TextBox 
{ 
  [ Browsable( false ) ] 
  public new bool WordWrap 
  { 
    get { return false; } // always false 
    set{} 
  } 
} 

[Visual Basic]

Public Class MyTextBox 
  Inherits TextBox 

  <Browsable(False)> _
  Public Shadows Property WordWrap() As Boolean 
    Get 
      Return False ' always false 
    End Get 
    Set ' empty 
    End Set 
  End Property 
End Class 

Contributed from George Shepherd's Windows Forms FAQ



Page view counter