1
我要強調選定的文本,但發現下劃線繼續到下一個製表 停止的RichTextBox:使用RichTextBox.Selection.start等選項卡式內容
示例代碼
//rtbList is a richTextBox
rtbList.AppendText("\t");
selStart = rtbList.TextLength;
rtbList.AppendText("Bought");
rtbList.SelectionStart = selStart;
rtbList.SelectionLength = rtbList.TextLength - selStart;
rtbList.SelectionFont = hdgFont; // bold & underline
rtbList.AppendText("\t");
//
selStart = rtbList.TextLength;
rtbList.SelectionLength = 0;
rtbList.AppendText("Maturity");
rtbList.SelectionStart = selStart;
rtbList.SelectionLength = rtbList.TextLength - selStart;
rtbList.SelectionFont = hdgFontNoUnderline;
反正是有要克服這個問題還是在rtf格式中是一個基本的「缺陷」?
[顯然我可以通過使用固定格式例如「信使」,構建字符串
用空格對齊文本。]
感謝LarsTech這肯定回答查詢 –
也提出了它肯定回答的問題。但我真正嘗試的是限制強調非空間字符!有什麼想法嗎? –
@MartinLord無論在RTB中選擇什麼,並且應用字體都會得到該字體。您需要從下劃線字體中排除非間隔字符,或者反過來,在應用非下劃線字體時包含非間距字符,這就是我的解決方案所做的。沒有用於從接收特定字體排除非空格字符的神奇公式。你必須選擇你的範圍並應用你的字體。 – LarsTech