Groups | Blog | Home
all groups > vb.net controls > june 2005 >

vb.net controls : UserControls And Properties


Stefan
6/23/2005 10:51:40 PM
Hi,

I've created a new usercontrol which has a label and a textbox on it. Like
in the code snippit below.

My problem is that when I use this control and set the value of the caption
to "TEST" via the properties window, once I build the application, the value
of the caption is resetted to the previous value.
Same for the Text propertie.

Can anyone tell me what the problem is? And give me a small example of how
I should do this?

Kind Regards

Stefan

Imports System.ComponentModel

Public Class MyTextBox
Inherits System.Windows.Forms.UserControl

<DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
_
Public Property Caption() As String
Get
Return lblCaption.Text
End Get
Set(ByVal Value As String)
lblCaption.Text = Value
End Set
End Property

<DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
_
Public Overrides Property Text() As String
Get
Return txtText.Text
End Get
Set(ByVal Value As String)
txtText.Text = Value
End Set
End Property
End Class

Tom John
7/13/2005 1:58:32 PM
[quoted text, click to view]


DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)>_
Public Overrides Property Text() As String
Get
Return MyBase.Text
End Get
Set(ByVal Value As String)
MyBase.Text = Value
Invalidate()
End Set
End Property


Hope this helps

AddThis Social Bookmark Button