default property not displayed in properties window. 
Author Message
 default property not displayed in properties window.

hi,

i am developing a windows control. my control exposes some
properties. one of these properties is as below:

    <DefaultValue("00.00"), _
    Description("Indicates the format used for displaying monetary
values."), _
    Browsable(True), _
    Category("MyCategory")> _
    Public Property CurrencyFormat() As String
        Get
            Return CURRENCY_FORMAT
        End Get
        Set(ByVal Value As String)
            CURRENCY_FORMAT = Value
            SetControlTemplates()
        End Set
    End Property

here i am clearly setting the default value to "00.00". but when i build and
put a control on a winform and look at the Properties Window the
"CurrencyFormat" is blank?

is this how its supposed to be? or is my understanding of its functionality
wrong?
i know i can get to this default in code but surely this should be displayed
in
the Properties window so that users of my control will know what the
default behaviour is??????

any ideas please?

thanks.

t.



Sun, 06 Mar 2005 23:20:35 GMT  
 default property not displayed in properties window.

Quote:

> hi,

> i am developing a windows control. my control exposes some
> properties. one of these properties is as below:

>     <DefaultValue("00.00"), _
>     Description("Indicates the format used for displaying monetary
> values."), _
>     Browsable(True), _
>     Category("MyCategory")> _
>     Public Property CurrencyFormat() As String
>         Get
>             Return CURRENCY_FORMAT
>         End Get
>         Set(ByVal Value As String)
>             CURRENCY_FORMAT = Value
>             SetControlTemplates()
>         End Set
>     End Property

> here i am clearly setting the default value to "00.00". but when i build
> and put a control on a winform and look at the Properties Window the
> "CurrencyFormat" is blank?

You need to set CURRENCY_FORMAT = "00.00" in the declaration or the
constructor or equivalent.  The DefaultValue attribute on a property doesn't
*set* anything.  It merely tells the property grid whether or not it should
1) Persist the value to code and 2) paint the value bolded or not. . .

--
Jacob Grass
Microsoft .NET MVP
Check out http://windowsforms.net



Sun, 06 Mar 2005 23:55:05 GMT  
 default property not displayed in properties window.

got any examples?

Quote:

> You need to set CURRENCY_FORMAT = "00.00" in the declaration or the
> constructor or equivalent.  The DefaultValue attribute on a property
doesn't
> *set* anything.  It merely tells the property grid whether or not it
should
> 1) Persist the value to code and 2) paint the value bolded or not. . .

> --
> Jacob Grass
> Microsoft .NET MVP
> Check out http://windowsforms.net



Mon, 07 Mar 2005 00:32:34 GMT  
 default property not displayed in properties window.

Quote:

> got any examples?

>> You need to set CURRENCY_FORMAT = "00.00" in the declaration or the
>> constructor or equivalent.  The DefaultValue attribute on a property
>> doesn't *set* anything.  It merely tells the property grid whether or
>> not it should 1) Persist the value to code and 2) paint the value bolded
>> or not. . .

Private CURRENCY_FORMAT As String = "00.00"

<DefaultValue("00.00")> _
Public Property CurrencyFormat() As String
    Get
        Return CURRENCY_FORMAT
    End Get
    Set(ByVal Value As String)
        CURRENCY_FORMAT = Value
    End Set
End Property

--
Jacob Grass
Microsoft .NET MVP
Check out http://windowsforms.net



Mon, 07 Mar 2005 00:41:27 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Display Text Property of a UserControl in the Property Window

2. Property Attributes - Help String displayed in property window.

3. Usercontrol Text property not visible in property window

4. Usercontrol Text property not visible in property window

5. How Can I Create a Property Windows Like VB5 Properties Window

6. Changing Printers property reset printer to Windows default printer

7. Windows Service - Security Properties - account property

8. Set Nothing to user-defined Image property through Properties Window

9. How to hide properties in the property window

10. Overridden property doesn't appear in Properties window

11. Edit usercontrol property in property window

12. UserControl and Property - Property Window

 

 
Powered by phpBB® Forum Software