将字体样式更改为richtextbox

时间:2014-05-21 13:37:25

标签: c# wpf richtextbox

我想在RichTextBox sp中更改字体样式。 我在WPF工作。

sp.FontStyle = FontStyle.Bold;

错误说:System.Windows.FontStyle' does not contain a definition for 'Bold' 我不知道,如果开始工作,如何改变。

1 个答案:

答案 0 :(得分:1)

您需要在 FontWeight -property:

中设置粗体
sp.FontWeight = FontWeights.Bold;

在WinForms中相同:

sp.Font = new Font(sp.Font.Name, sp.Font.Size, FontStyle.Bold);