[英]How to change font of a selected text in richtextbox
我想更改名為Notes的 Richtextbox 中選定文本的字體
我嘗試使用此代碼,但它不起作用
Notes.SelectionFont = FontStyle.Italic;
有人能幫我嗎?
嘗試這個; Select 一個文本然后觸發
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);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.