Results 1 to 3 of 3

Thread: user control problem

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    403

    user control problem

    hi all,

    i created a user control and inherited a textbox.

    is it possible to remove some of the inherited properties of the user control?

    like to Multi-Line, PasswordChar etc... also at the Form Design, when selecting the user control, there's an arrow on the upper-right which i also want to remove. how can i do this?

    thanks

    VB Version: Microsoft Visual Studio 2008 Professional Edition
    .NET Version: Microsoft .NET Framework Version 3.5
    OS: Windows XP SP3

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: user control problem

    First up, a user control is a class that inherits UserControl. If you inherited TextBox then it's more correctly a custom control.

    As for the first question, you can't actually remove an inherited member. All you can do is hide the member from the IDE. The following code creates a custom TextBox control that will not display its Multiline property in either the design window or the Intellisense lists in the code window:
    vb.net Code:
    1. Imports System.ComponentModel
    2.  
    3. Public Class TextBoxEx
    4.     Inherits TextBox
    5.  
    6.     <EditorBrowsable(EditorBrowsableState.Never), Browsable(False)> _
    7.     Public Shadows Property Multiline() As Boolean
    8.         Get
    9.             Return MyBase.Multiline
    10.         End Get
    11.         Set(ByVal value As Boolean)
    12.             MyBase.Multiline = value
    13.         End Set
    14.     End Property
    15.  
    16. End Class
    The member still exists, so it can still be accessed in code. you just won't get any help from the IDE to do so.

    As for the last question, that is called a smart tag and is created using XML. I don't how you'd remove it, or even if you can, but if you were to read up about how they're created in the first place then that might lead you to a way to remove it in a derived class.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    403

    Re: user control problem

    thanks...

    this is able to hide the property at design time...

    i did try a few search regarding the smart tag and came across a thread that suggested i should override the PostFilterProperties.

    Code:
        Protected Overridable Sub PostFilterProperties(ByVal properties As IDictionary)
            With properties
                .Remove("Multiline")
            End With
        End Sub
    can't get it to work yet... still digging.

    VB Version: Microsoft Visual Studio 2008 Professional Edition
    .NET Version: Microsoft .NET Framework Version 3.5
    OS: Windows XP SP3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width