Tag: bold

需要使用javascript将所选文本设置为粗体/斜体/下划线,并使用c#保存和检​​索相同的文本

我需要使用javascript制作文本框粗体/斜体/下划线的选定文本。 为此,我使用以下代码。 function changeFont(txt, change) { if (change == ‘b’) { if (document.getElementById(txt).style.fontWeight == ‘bold’) document.getElementById(txt).style.fontWeight = ‘normal’; else document.getElementById(txt).style.fontWeight = ‘bold’; } else if (change == ‘i’) { if (document.getElementById(txt).style.fontStyle == ‘italic’) document.getElementById(txt).style.fontStyle = ‘normal’; else document.getElementById(txt).style.fontStyle = ‘italic’; } else { if (document.getElementById(txt).style.textDecoration == ‘underline’) document.getElementById(txt).style.textDecoration = ‘none’; else document.getElementById(txt).style.textDecoration = ‘underline’; } […]

如何在C#中的富文本框中使某些文本变为粗体

我想创建一个文本编辑器,我可以使文本变粗,改变颜色等。 我发现这段代码大致有效: public static void BoldSelectedText(RichTextBox control) { control.SelectionFont = new Font(control.Font.FontFamily, control.Font.Size, FontStyle.Bold); } 但是当我在RichTextBox输入更多字母时,文本仍然是粗体。 除非我选择文本并点击“Make Bold”按钮,否则我怎样才能使所选文本只是粗体而下一个字符不是?