Help with Default Property

M

millerchris40

I created a UserControl that has a MaskedTextBox in it. It works. I
have a BorderStyle property defined as:

<Browsable(True),
DefaultValue(System.Windows.Forms.BorderStyle.Fixed3D),
Description("Indicates whether the EnhancedTextBox will have a
border.")> _
Public Overloads Property BorderStyle() As
System.Windows.Forms.BorderStyle
Get
Return MaskedTextBox1.BorderStyle
End Get
Set(ByVal value As System.Windows.Forms.BorderStyle)
MaskedTextBox1.BorderStyle = value
End Set
End Property

It works fine. However, when I place an instance of this control on a
form, the BorderStyle property is displayed in the Properties Window
of the form in Bold. It's not recognizing the Fixed3D as the default
value. I have other properties that are doing the same thing.

However, some of my properties that I have (Enabled, for example) do
display not in bold when the value of the property is it's default
value:

<Browsable(True), DefaultValue(True), Description("Indicates
whether the EnhancedTextBox is enabled.")> _
Public Overloads Property Enabled() As Boolean
Get
Return MaskedTextBox1.Enabled
End Get
Set(ByVal value As Boolean)
MaskedTextBox1.Enabled = value
TextBox1.Enabled = value
End Set
End Property

Can anyone tell me why?
 
M

millerchris40

OK, I figured it out. I had to write the DefaultValue a littler
differently. Here is the code:

<Browsable(True),
DefaultValue(GetType(System.Windows.Forms.BorderStyle), "2"),
Description("Indicates whether the EnhancedTextBox will have a
border.")> _
Public Overloads Property BorderStyle() As
System.Windows.Forms.BorderStyle
Get
Return MaskedTextBox1.BorderStyle
End Get
Set(ByVal value As System.Windows.Forms.BorderStyle)
MaskedTextBox1.BorderStyle = value
TextBox1.BorderStyle = value
End Set
End Property
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top