How to change the font property of a tab control without changing the font of its child controls in C#?

允我心安 提交于 2020-01-03 20:57:18

问题


I want to change the font of a tab control because I want the text in the tab page headers to look bigger. But when I change the font property of a tab control in the Designer (I'm using MS VStudio 2010), the font of its child controls change as well (such as labels and treeview) which I don't intend to do. I just want to change the tab pages' header's font.

edit: i thought of changing the font property (if there is) of the child controls of the tab control in code by looping through the child controls. would there be any problem with this idea?


回答1:


Font property in most of the Win-Forms control like Label is defined as explained below.

    The Font property is an ambient property. An ambient property is a control 
property that, if not set, is retrieved from the parent control. For example, a 
    Button will have the same BackColor as its parent Form by default

If you want to specify some font at parent level which you don't want to be inherited by child you will have to manually assign child controls some other font



来源:https://stackoverflow.com/questions/8892490/how-to-change-the-font-property-of-a-tab-control-without-changing-the-font-of-it

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!