为什么在用户控件中覆盖的文本属性在设计时未显示 [英] Why does the text property overridden in user control is not showing at design time

查看:30
本文介绍了为什么在用户控件中覆盖的文本属性在设计时未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个覆盖文本属性的用户控件.但是这个属性在设计时不会显示.

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

怎么办?

推荐答案

添加以下属性,问题解决.

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

这篇关于为什么在用户控件中覆盖的文本属性在设计时未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆