Simonetos Simonetos - 6 months ago 17
Vb.net Question

VB.NET - Font property issue in custom usercontrol

I am working on a visual basic project builded using Visual Studio 2015. I have make a custom

usercontrol
that contains a
RectangleShape
and a
textbox
. Into
usercontrol
code I have added font properties...

Public Overrides Property Font() As Font
Get
Return TextBox.Font
End Get
Set(ByVal value As Font)
TextBox.Font = value
End Set
End Property


So I load my custom
usercontrol
to my project and for example, I change font's size.

enter image description here

My problem is that I can see the changes into design mode but not into run mode where shows the default font size!!!

enter image description here

Any idea?

Answer

HansPassant gave the answer to this question!!! So, To help other people who may have the same question, this is how my custom font property should look...

Public Overrides Property Font() As Font
    Get
        Return MyBase.Font
    End Get
    Set(ByVal value As Font)
        MyBase.Font = value
        TextBox.Font = value
    End Set
End Property
Comments