User Control Properties

psmocko

New member
Joined
Mar 11, 2008
Messages
4
Programming Experience
5-10
I have developed a user control with the following property.

<DefaultValue(GetType(System.Boolean), "True"), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
Public Property Required() As Boolean
Get
Return _Required
End Get
Set(ByVal value As Boolean)
_Required = value
End Set
End Property

I am having trouble with the property persisting from design time to runtime. The form I have has multiple instances of this control on it and when I set this property at design time, then close the form, it is not set correctly when I open the form designer again. Any help is appreciated.

thanks,
Paul
 
Set _Required to same value as the DefaultValue (True). What happens is that when you set the value to the default in Designer the property isn't serialized to the Designer generated code. Later when the Designer again tries to look up the value it looks first in generated code and finds nothing, then queries the class property and gets _Required (which is False when not set).
 
Thanks John,

I see what you are saying...Will try that. Sorry about the post formatting, I am new to posting to the forum.
 
Back
Top