views:

110

answers:

2

I have a usercontrol which overrides the property Text. But this property is not shown at design time.

If I rename it to caption or value it is shown in properties at design time but Text is not shown.

public Class SomeControl
    Inherits System.Windows.Forms.UserControl

    Public Overrides Property Text() As String
        Get
            Return lblText.Text
        End Get
        Set(ByVal value As String)
            lblText.Text = value
        End Set
    End Property
End Class

What to do?

+1  A: 

Hey,

The Text property is defined as:

[Bindable(false), EditorBrowsable(EditorBrowsableState.Never), Browsable(false),
 DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

Meaning, you can't browse it in the property window; you need to override the property attributes defined here (which I don't know if that will work as expected) or just set the property name to something else.

HTH.

Brian
I got the answer and posted it
Sachin
+1  A: 

Added following attributes and the problem is solved.

    <EditorBrowsable(EditorBrowsableState.Always)> _
    <Browsable(True)> _
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
    <Bindable(True)> _
    Public Overrides Property Text() As String
        Get
            Return lblText.Text
        End Get
        Set(ByVal value As String)
            lblText.Text = value
        End Set
    End Property
Sachin