Unable to set Default value for UserControl property

A

Atchoum

I have the following property in one UserControl. When I use the control,
the description appears Ok but the default value is stuck at False.
What am I doing wrong?
<System.ComponentModel.DefaultValue(True), _
Description("Indicates whether users with Browse rights should be
displayed")> _
Property ShowBrowseRole() As Boolean

Get
Return m_bBrowseRole
End Get

Set(ByVal Value As Boolean)
m_bBrowseRole = Value
End Set

End Property

TIA
 
K

Ken Tucker [MVP]

Hi,

Dim m_bBrowseRole as Boolean = True

Ken
------------------
I have the following property in one UserControl. When I use the control,
the description appears Ok but the default value is stuck at False.
What am I doing wrong?
<System.ComponentModel.DefaultValue(True), _
Description("Indicates whether users with Browse rights should be
displayed")> _
Property ShowBrowseRole() As Boolean

Get
Return m_bBrowseRole
End Get

Set(ByVal Value As Boolean)
m_bBrowseRole = Value
End Set

End Property

TIA
 
H

Herfried K. Wagner [MVP]

* "Atchoum said:
I have the following property in one UserControl. When I use the control,
the description appears Ok but the default value is stuck at False.
What am I doing wrong?
<System.ComponentModel.DefaultValue(True), _
Description("Indicates whether users with Browse rights should be
displayed")> _

\\\
Private m_bBrowseRole As Boolean = True
///
 
A

Atchoum

Thanks for your response. I know I can do it this way.
But is this to mean that ComponentModel.DefaultValue does not work properly?
 
H

Herfried K. Wagner [MVP]

* "Atchoum said:
Thanks for your response. I know I can do it this way.
But is this to mean that ComponentModel.DefaultValue does not work properly?

This attribute is for the designer only. It will add a "Reset" menu
item to the property's context menu in the properties window that will
reset it to the value provided in this attribute.
 
A

Atchoum

Thanks for the explanation. I misinterpreted what I read somewhere then. I
really appreciate it.
 

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