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