如何在 C# 中更改选项卡控件的字体属性而不更改其子控件的字体? [英] How to change the font property of a tab control without changing the font of its child controls in C#?

查看:50
本文介绍了如何在 C# 中更改选项卡控件的字体属性而不更改其子控件的字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改选项卡控件的字体,因为我希望选项卡页标题中的文本看起来更大.但是,当我在设计器中更改选项卡控件的字体属性时(我使用的是 MS VStudio 2010),其子控件的字体也会更改(例如标签和树视图),这是我不打算做的.我只想更改标签页的标题字体.

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?

推荐答案

Font 属性在大多数 Win-Forms 控件中,如 Label定义如下.

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

这篇关于如何在 C# 中更改选项卡控件的字体属性而不更改其子控件的字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆