# How to assign a default TextFont to a custom Label control?

**URL:** <https://forum.xojo.com/t/how-to-assign-a-default-textfont-to-a-custom-label-control/34511>\
**Category:** General\
**Created:** [November 16, 2016, 1:54pm UTC](https://forum.xojo.com/t/how-to-assign-a-default-textfont-to-a-custom-label-control/34511 "2016-11-16T13:54:57Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sébastien\_Angot](https://forum.xojo.com/user_avatar/forum.xojo.com/s%C3%A9bastien_angot/32/11094_2.png) [@Sébastien\_Angot](https://forum.xojo.com/u/S%C3%A9bastien_Angot)\
**Post date:** [November 16, 2016, 1:54pm UTC](https://forum.xojo.com/t/how-to-assign-a-default-textfont-to-a-custom-label-control/34511/1 "2016-11-16T13:54:57Z")

</div>

Hello

I would like to create a custom Label for all my titles, with a specific TextFont.

How can I set a new default TextFont on my custom Label class? I don’t know how to access the control’s properties, maybe am I too tired ^^

Any advice? Thank you!

---

<div class="post-metadata">

**Author:** ![shao\_sean](https://forum.xojo.com/letter_avatar_proxy/v4/letter/s/ed8c4c/32.png) [@shao\_sean](https://forum.xojo.com/u/shao_sean)\
**Post date:** [November 16, 2016, 2:01pm UTC](https://forum.xojo.com/t/how-to-assign-a-default-textfont-to-a-custom-label-control/34511/2 "2016-11-16T14:01:57Z")

</div>

[http://documentation.xojo.com/index.php/Label.TextFont](http://documentation.xojo.com/index.php/Label.TextFont)

---

<div class="post-metadata">

**Author:** ![Sébastien\_Angot](https://forum.xojo.com/user_avatar/forum.xojo.com/s%C3%A9bastien_angot/32/11094_2.png) [@Sébastien\_Angot](https://forum.xojo.com/u/S%C3%A9bastien_Angot)\
**Post date:** [November 16, 2016, 2:03pm UTC](https://forum.xojo.com/t/how-to-assign-a-default-textfont-to-a-custom-label-control/34511/3 "2016-11-16T14:03:54Z")

</div>

I already read this and it does not answer my question.

I would like to change the default TextFont of my custom Label control in order to see my own properties in the IDE when I use this control.

---

<div class="post-metadata">

**Author:** ![shao\_sean](https://forum.xojo.com/letter_avatar_proxy/v4/letter/s/ed8c4c/32.png) [@shao\_sean](https://forum.xojo.com/u/shao_sean)\
**Post date:** [November 16, 2016, 2:11pm UTC](https://forum.xojo.com/t/how-to-assign-a-default-textfont-to-a-custom-label-control/34511/4 "2016-11-16T14:11:05Z")

</div>

Weird… I thought setting the Inspector Behaviour would cause it to set the font, but apparently you need to do it in your subclass Open event… This worked for me…

[code]Sub Open() Handles Open  
me.TextFont = “Arial”

RaiseEvent Open  
End Sub  
[/code]

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [November 16, 2016, 2:27pm UTC](https://forum.xojo.com/t/how-to-assign-a-default-textfont-to-a-custom-label-control/34511/5 "2016-11-16T14:27:06Z")

</div>

It’s in `Inspector Behavior`  
 ![](http://timi.me/.misc/Screen%20Shot%202016-11-16%20at%2009.28.09.png)

Also, Hi shao sean! Welcome back!

---

<div class="post-metadata">

**Author:** ![Sébastien\_Angot](https://forum.xojo.com/user_avatar/forum.xojo.com/s%C3%A9bastien_angot/32/11094_2.png) [@Sébastien\_Angot](https://forum.xojo.com/u/S%C3%A9bastien_Angot)\
**Post date:** [November 16, 2016, 2:44pm UTC](https://forum.xojo.com/t/how-to-assign-a-default-textfont-to-a-custom-label-control/34511/6 "2016-11-16T14:44:27Z")

</div>

Thanks for your answers!

I tried, as you can see on my screenshots, but when I drag’n drop my custom control in a window, the TextFont is still «System» and FontSize still 0…

![](https://dl.dropboxusercontent.com/u/14372591/screenshots/xojo-screenshot-custom-label-text-font.png)

In a window :  
 ![](https://dl.dropboxusercontent.com/u/14372591/screenshots/xojo-screenshot-custom-label-text-font.jpg)

---

<div class="post-metadata">

**Author:** ![shao\_sean](https://forum.xojo.com/letter_avatar_proxy/v4/letter/s/ed8c4c/32.png) [@shao\_sean](https://forum.xojo.com/u/shao_sean)\
**Post date:** [November 16, 2016, 2:44pm UTC](https://forum.xojo.com/t/how-to-assign-a-default-textfont-to-a-custom-label-control/34511/7 "2016-11-16T14:44:55Z")

</div>

Hi Tim (thanks for the warm greetings 🙂 )

I tried changing it in there, but it didn’t make a difference, either in the IDE or in the debug build…

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [November 16, 2016, 2:49pm UTC](https://forum.xojo.com/t/how-to-assign-a-default-textfont-to-a-custom-label-control/34511/8 "2016-11-16T14:49:22Z")

</div>

Oh I think I might have an uninformed guess as to why that might be.  
Calling in @Norman Palardy though because I can confirm the behavior described.

---

<div class="post-metadata">

**Author:** ![Sébastien\_Angot](https://forum.xojo.com/user_avatar/forum.xojo.com/s%C3%A9bastien_angot/32/11094_2.png) [@Sébastien\_Angot](https://forum.xojo.com/u/S%C3%A9bastien_Angot)\
**Post date:** [November 16, 2016, 2:51pm UTC](https://forum.xojo.com/t/how-to-assign-a-default-textfont-to-a-custom-label-control/34511/9 "2016-11-16T14:51:23Z")

</div>

@shao sean : I also tried your solution, but it does not work for me…  
 ![](https://dl.dropboxusercontent.com/u/14372591/screenshots/xojo-screenshot-custom-label-text-font-1.jpg)

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [November 16, 2016, 2:59pm UTC](https://forum.xojo.com/t/how-to-assign-a-default-textfont-to-a-custom-label-control/34511/10 "2016-11-16T14:59:25Z")

</div>

That should change the font only when the app runs, you won’t see it in the IDE.

---

<div class="post-metadata">

**Author:** ![shao\_sean](https://forum.xojo.com/letter_avatar_proxy/v4/letter/s/ed8c4c/32.png) [@shao\_sean](https://forum.xojo.com/u/shao_sean)\
**Post date:** [November 16, 2016, 3:01pm UTC](https://forum.xojo.com/t/how-to-assign-a-default-textfont-to-a-custom-label-control/34511/11 "2016-11-16T15:01:28Z")

</div>

Create an EventDefinition called Open…

---

<div class="post-metadata">

**Author:** ![Sébastien\_Angot](https://forum.xojo.com/user_avatar/forum.xojo.com/s%C3%A9bastien_angot/32/11094_2.png) [@Sébastien\_Angot](https://forum.xojo.com/u/S%C3%A9bastien_Angot)\
**Post date:** [November 16, 2016, 3:02pm UTC](https://forum.xojo.com/t/how-to-assign-a-default-textfont-to-a-custom-label-control/34511/12 "2016-11-16T15:02:26Z")

</div>

> [@298687:@Tim Parnell](#):
>
> That should change the font only when the app runs, you won’t see it in the IDE.

Yes it’s exactly what I supposed, but I want to work in the IDE with the new properties (TextFont and FontSize).

I’m wondering if it’s possible or not… It should be I imagine…

---

<div class="post-metadata">

**Author:** ![Sébastien\_Angot](https://forum.xojo.com/user_avatar/forum.xojo.com/s%C3%A9bastien_angot/32/11094_2.png) [@Sébastien\_Angot](https://forum.xojo.com/u/S%C3%A9bastien_Angot)\
**Post date:** [November 16, 2016, 3:10pm UTC](https://forum.xojo.com/t/how-to-assign-a-default-textfont-to-a-custom-label-control/34511/13 "2016-11-16T15:10:27Z")

</div>

After all, I don’t understand why it does not work by changing the default value in the Inspector Behavior…

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [November 16, 2016, 3:50pm UTC](https://forum.xojo.com/t/how-to-assign-a-default-textfont-to-a-custom-label-control/34511/14 "2016-11-16T15:50:54Z")

</div>

Give the staff time to wake up. I think Norman should look at this thread before we jump to conclusions.

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [November 16, 2016, 5:11pm UTC](https://forum.xojo.com/t/how-to-assign-a-default-textfont-to-a-custom-label-control/34511/15 "2016-11-16T17:11:46Z")

</div>

AFAIK, properties set in the class do not propagate to the instance. Indeed you have to set the font in the Open event.

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [November 16, 2016, 5:17pm UTC](https://forum.xojo.com/t/how-to-assign-a-default-textfont-to-a-custom-label-control/34511/16 "2016-11-16T17:17:57Z")

</div>

If you set properties in `Inspector Behavior...` they become the default values when the control is added to the design view in the IDE. You can also control (for the most part) which properties are visible to the developer.

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [November 16, 2016, 7:02pm UTC](https://forum.xojo.com/t/how-to-assign-a-default-textfont-to-a-custom-label-control/34511/17 "2016-11-16T19:02:57Z")

</div>

Not in this case 😛  
What is your preference setting for Preferences \> Layout \> default control font and size set to ?  
That will override everything else  
This has been true for many years but maybe there should be a way to turn this behaviour off

---

<div class="post-metadata">

**Author:** ![Sébastien\_Angot](https://forum.xojo.com/user_avatar/forum.xojo.com/s%C3%A9bastien_angot/32/11094_2.png) [@Sébastien\_Angot](https://forum.xojo.com/u/S%C3%A9bastien_Angot)\
**Post date:** [November 16, 2016, 10:25pm UTC](https://forum.xojo.com/t/how-to-assign-a-default-textfont-to-a-custom-label-control/34511/18 "2016-11-16T22:25:06Z")

</div>

In Preferences \> Layout, the default font is System and FontSize 0, but I don’t know how to override this.

If XOJO allows us to change the value in Inspector Behavior, I don’t understand why it does not take these changes…

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [November 16, 2016, 10:42pm UTC](https://forum.xojo.com/t/how-to-assign-a-default-textfont-to-a-custom-label-control/34511/19 "2016-11-16T22:42:25Z")

</div>

It is not terribly difficult to add a menu definition for Open, add a bit of code in the Open event of the custom class to change the font and font size, and raise the event at the end of the custom class Open.

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [November 16, 2016, 10:56pm UTC](https://forum.xojo.com/t/how-to-assign-a-default-textfont-to-a-custom-label-control/34511/20 "2016-11-16T22:56:49Z")

</div>

Reread my post

It does take them - then overrides them with the settings in Default Control font & Size  
Thats why

Its also why I said [quote=298733:@Norman Palardy] maybe there should be a way to turn this behaviour off[/quote]

[Next page](https://forum.xojo.com/t/how-to-assign-a-default-textfont-to-a-custom-label-control/34511.md?page=2)
