我想更改名为 Notes
的富文本框中选定文本的字体我尝试使用此代码但它不起作用
Notes.SelectionFont = FontStyle.Italic;
有人可以帮我吗?
答案 0 :(得分:1)
试试这个; 选择一个文本然后触发
private void button1_Click(object sender, EventArgs e)
{
int selstart = richTextBox1.SelectionStart;
int sellength = richTextBox1.SelectionLength;
richTextBox1.SelectionFont = new Font(richTextBox1.Font, FontStyle.Italic);
richTextBox1.SelectionStart = richTextBox1.SelectionStart + richTextBox1.SelectionLength;
richTextBox1.SelectionLength = 0;
richTextBox1.SelectionFont = richTextBox1.Font;
richTextBox1.Select(selstart, sellength);
}