Sha*_*lan 4 formatting richtextbox winforms
从标题中可以看出,我在RichTexBox控件中为所选文本分配和删除格式样式时遇到了一些问题.
我知道如何单独制作文字粗体/斜体/下划线,但不是这些的组合.我知道可以通过角色实现这个角色的方法,但这在界面上看起来很耗时.如果它可以在Wordpad中毫不费力地完成,我相信它可以在这里实现!
是否存在可以允许我从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;
Run Code Online (Sandbox Code Playgroud)