Initialize DefaultPropertyAttribute for a Object property

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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)
 
Theo Verweij said:
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)

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.
 
Back
Top