2005 Custom Control

C

Chris Oswald

Forgive me if this has already been answered. I have created a custom
control which inherits from Windows.Forms.Control. I want set a
default Font for the Font property when the control is originally
created in the designer. I set the default font in the constructor.
Except the designer ignores my information and draws the control with
the it's own font of "Tahoma", 9F, Regular. WTF! If I create some
dummy property called ButtonFont the font works just fine in the
designer. What is the deal?


Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()

' Add any initialization after the InitializeComponent() call.
Me.Font = New Font("Tahoma", 15.0F, FontStyle.Bold)
End Sub

Private _font As Font
Public Overrides Property Font() As Font
Get
Return _font
End Get
Set(ByVal value As Font)
_font = value
Me.Invalidate()
End Set
End Property
 
C

Chris Oswald

You are the man. I saw that article referenced somewhere else and
didn't read far enough.

The key is :

<ApplyDeviceDefaults>
<PropertyName>Font</PropertyName>
<ApplyDefaults>false</ApplyDefaults>
</ApplyDeviceDefaults>

Thank you Tim!
 

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