选项卡控件的粗体文本 [英] Bold text for a tab control

查看:26
本文介绍了选项卡控件的粗体文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在某些条件下(不一定是 GotFocus)将标签页的文本加粗.是否真的唯一更简单的方法是覆盖选项卡控件的 DrawItem 事件?

I'd like to bold the text for a tab page under certain conditions (not, necessarily, GotFocus). Is it true the only 'er easiest way to do this is by overriding the DrawItem event for the tab control?

http://www.vbforums.com/showthread.php?t=355093

似乎应该有更简单的方法.

It seems like there should be an easier way.

喜欢...

<代码>tabControl.TabPages(index).Font = New Font(Me.Font, FontStyle.Bold)

这显然行不通.

推荐答案

在 TabPage 上设置 Font 属性时,就是在为该选项卡页上的所有控件设置默认字体.但是,您没有为标题设置它.

When you set the Font property on a TabPage, you are setting the default font for all controls on that tab page. You are not setting it for the header, however.

当您执行以下代码时:

tabControl.TabPages(index).Font = New Font(Me.Font, FontStyle.Bold)

该页面上的任何控件现在默认为粗体,这不是(我假设)您想要的.

Any controls on that page will now be bold by default, which is not (I'm assuming) what you want.

标题的字体(即选项卡本身)由 TabControl 的 Font 属性控制.如果您要将代码更改为:

The header's font (that is, the tab itself) is controlled by the TabControl's Font property. If you were to change your code to:

tabControl.Font = New Font(Me.Font, FontStyle.Bold)

你会看到它在行动.但是,它会更改显示的所有标签的字体,我假设这也不是您想要的.

You will see that in action. However, it changes the font for all the tabs on display, which is also not, I'm assuming, what you want.

因此,使用默认的 WinForms 选项卡控件,您(我相信)仅限于您发布的链接中的技术.或者,您可以开始查看 3rd-party 控件,例如 这些 问题StackOverflow 上.

So, using the default WinForms tab control, you are (I believe) limited to the technique in the link you've posted. Alternatively, you can begin looking at 3rd-party controls, such as those discussed in these questions on StackOverflow.

这篇关于选项卡控件的粗体文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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