C# 如何更改文本的字体样式
如何更改字体样式(常规、粗体等) 到目前为止,我得到的是:C# 如何更改文本的字体样式,c#,.net,fonts,styles,C#,.net,Fonts,Styles,如何更改字体样式(常规、粗体等) 到目前为止,我得到的是: if (listBox1.SelectedIndex == 3) { if (textBox1.Text == "regular") { //FontStyle regular = new FontStyle !!!wrong one!!! } } 所以我需要的是,当我在文本框中键入“regular”时,字体样式将更改为regular。怎么做?您需要设置属性 你在找这样的东西吗: textBox1.Fo
if (listBox1.SelectedIndex == 3)
{
if (textBox1.Text == "regular")
{
//FontStyle regular = new FontStyle !!!wrong one!!!
}
}
所以我需要的是,当我在文本框中键入“regular”时,字体样式将更改为regular。怎么做?您需要设置属性
你在找这样的东西吗:
textBox1.Font = new Font(textBox1.Font, FontStyle.Bold);
您需要创建新字体并将其应用于文本框:
textBox1.Font = new Font(FontFamily.GenericSansSerif, 12.0F, FontStyle.Normal);
这将创建一个具有新族等的字体。您可以从现有字体对象中读取大小和族以保留这些大小和族
textBox1.Font = new Font(textBox1.Font, FontStyle.Normal);
有关字体类属性的更多信息,请参阅
textBox1.Font = new Font(textBox1.Font, FontStyle.Normal);