Why does the text property overridden in user control is not showing at design time

后端 未结 2 2077
Happy的楠姐
Happy的楠姐 2021-02-13 14:04

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 de

相关标签:
2条回答
  • 2021-02-13 14:41

    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
    
    0 讨论(0)
  • 2021-02-13 14:42

    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.

    0 讨论(0)
提交回复
热议问题