Sac*_*van 13 vb.net user-controls
我有一个usercontrol覆盖属性Text.但是这个属性在设计时没有显示.
如果我将其重命名为标题或值,它将在设计时显示在属性中,但不显示文本.
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
Run Code Online (Sandbox Code Playgroud)
该怎么办?
Sac*_*van 15
添加了以下属性并解决了问题.
<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
Run Code Online (Sandbox Code Playgroud)