正如您从标题中可以看出的,我在向 RichTexBox 控件中的选定文本分配和删除格式样式方面遇到了一些问题。
我知道如何单独制作文本粗体/斜体/下划线,但不知道如何组合这些。我知道可以逐个字符地实现此目的的方法,但这在界面上似乎很耗时。如果可以在写字板中轻松完成,我相信在这里也能实现!
是否没有这样的方法或类似的方法可以让我从RichTextBox.SelectedFont“添加”或“删除”样式?
最佳答案
除非我完全误解了这个问题
// Get the current text selection or to text entered after the insertion point.
// Build new font based on the selection font, make it both Bold and Underline
// Apply new font to currently selected text (or for new text at insertion point
Font currFont = richTextBox.SelectionFont;
Font boldUnderFont = new Font(currFont, FontStyle.Bold | FontStyle.Underline);
richTextBox.SelectionFont = boldUnderFont;
关于Winforms RichtextBox 粗体/斜体/下划线格式问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1252040/