zoukankan      html  css  js  c++  java
  • richTextBox设置选中的字体属性

    执行一次设置选中的字体样式 再执行一次恢复正常

    //粗体


    public
    void ToggleBold() {
    if (richTextBox1.SelectionFont == null) richTextBox1.SelectionFont = richTextBox1.Font; FontStyle style = richTextBox1.SelectionFont.Style; if (richTextBox1.SelectionFont.Bold) style &= ~FontStyle.Bold;//恢复正常 else style |= FontStyle.Bold; richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont, style); }

    斜体


    public
    void ToggleItalic() { if (richTextBox1.SelectionFont == null) richTextBox1.SelectionFont = richTextBox1.Font; FontStyle style = richTextBox1.SelectionFont.Style; if (richTextBox1.SelectionFont.Italic) style &= ~FontStyle.Italic;//恢复正常 else style |= FontStyle.Italic; richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont, style); }

    下划线


    public
    void ToggleUnderLine() { if (richTextBox1.SelectionFont == null) richTextBox1.SelectionFont = richTextBox1.Font; FontStyle style = richTextBox1.SelectionFont.Style; if (richTextBox1.SelectionFont.Underline) style &= ~FontStyle.Underline;//恢复正常 else style |= FontStyle.Underline; richTextBox1.SelectionFont = new Font(richTextBox1.SelectionFont, style); }
  • 相关阅读:
    JSP数据交互(一)
    response.setHeader()用法
    Vue初步认识
    Socket初步了解
    DOM4j的修改删除方式
    多线程
    ArrayList和Vector区别
    集合框架(一)
    深入C#数据类型
    深入.NET框架
  • 原文地址:https://www.cnblogs.com/xe2011/p/3446072.html
Copyright © 2011-2022 走看看