我如何在运行时设置文本框的文本大胆? [英] How do I set a textbox's text to bold at run time?

查看:86
本文介绍了我如何在运行时设置文本框的文本大胆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Windows窗体,我有一个文本框,我偶尔会想使文本加粗,如果它有一定的价值。

I'm using Windows forms and I have a textbox which I would occassionally like to make the text bold if it is a certain value.

我如何改变在运行时的字体特点?

How do I change the font characteristics at run time?

我看到有一个叫textbox1.Font.Bold财产,但,这是一个获得唯一的财产。

I see that there is a property called textbox1.Font.Bold but this is a Get only property.

推荐答案

本身是只读的字体的bold属性,但文本框的实际字体属性不是。你可以改变文本框大胆的字体如下:

The bold property of the font itself is read only, but the actual font property of the text box is not. You can change the font of the textbox to bold as follows:

  textBox1.Font = new Font(textBox1.Font, FontStyle.Bold);



然后再回到:

And then back again:

  textBox1.Font = new Font(textBox1.Font, FontStyle.Regular);

这篇关于我如何在运行时设置文本框的文本大胆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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