Home All Groups Group Topic Archive Search About

Initialize DefaultPropertyAttribute for a Object property

Author
5 Nov 2006 2:58 PM
SparkPlug
Does anyone know how to initialize a DefaultPropertyAttribute for a
object-type property, for example if you want to set the default value of a
Font property to a particular font? E.g.:

    <DefaultValue(...)> _
    Public Property HeaderFont() As Font
        Get
            Return _headerFont
        End Get
        Set(ByVal value As Font)
            _headerFont = value
        End Set
    End Property

....where I want to set the default value for the HeaderFont property to
something like Font("Arial", 16, FontStyle.Bold)

Many thanks.

Author
5 Nov 2006 5:42 PM
Theo Verweij
How to do it with an attribute, I don't know.
But initialising a default property value is quite simple:

Private _headerFont as font = new Font("Arial", 16, FontStyle.Bold)


SparkPlug wrote:
Show quoteHide quote
> Does anyone know how to initialize a DefaultPropertyAttribute for a
> object-type property, for example if you want to set the default value of a
> Font property to a particular font? E.g.:
>
>     <DefaultValue(...)> _
>     Public Property HeaderFont() As Font
>         Get
>             Return _headerFont
>         End Get
>         Set(ByVal value As Font)
>             _headerFont = value
>         End Set
>     End Property
>
> ....where I want to set the default value for the HeaderFont property to
> something like Font("Arial", 16, FontStyle.Bold)
>
> Many thanks.
>
Author
6 Nov 2006 5:11 PM
SparkPlug
Show quote Hide quote
"Theo Verweij" wrote:

> How to do it with an attribute, I don't know.
> But initialising a default property value is quite simple:
>
> Private _headerFont as font = new Font("Arial", 16, FontStyle.Bold)
>
>
> SparkPlug wrote:
> > Does anyone know how to initialize a DefaultPropertyAttribute for a
> > object-type property, for example if you want to set the default value of a
> > Font property to a particular font? E.g.:
> >
> >     <DefaultValue(...)> _
> >     Public Property HeaderFont() As Font
> >         Get
> >             Return _headerFont
> >         End Get
> >         Set(ByVal value As Font)
> >             _headerFont = value
> >         End Set
> >     End Property
> >
> > ....where I want to set the default value for the HeaderFont property to
> > something like Font("Arial", 16, FontStyle.Bold)
> >

Thanks for your answer. I will assume for now that is the only way to do it
as I have not found any other way.