尝试将字体样式更改为下划线1行,并在常规样式中打印下一行对我不起作用。我正在尝试这样的事情: -
textBox1.Font = new Font(textBox1.Font, FontStyle.Underline);
textBox1.Text+="This line should be underlined";
textBox1.Font = new Font(textBox1.Font, FontStyle.Regular);
textBox1.Text+=Environment.NewLine;
textBox1.Text+="This line should be normal";
但是一切都是在影响FontStyle的最后一行完成,在本例中是Regular。如果我删除第3行,则所有内容均为下划线。
答案 0 :(得分:1)
普通TextBox
通常只支持一种风格。它的值只是一个字符串,而不是带有格式信息的字符串。
相反,请使用RichTextBox
(WinForms)/ RichTextBox
(WPF)。