博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
richTextBoxFontClass
阅读量:4307 次
发布时间:2019-06-06

本文共 2654 字,大约阅读时间需要 8 分钟。

使用

private void button1_Click(object sender, EventArgs e){    RichTextBoxCtrl.richTextBoxFontClass r = new RichTextBoxCtrl.richTextBoxFontClass();    r.richTextBox = richTextBox1;    r.ToggleBold();}

 

 

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows.Forms;using System.Drawing;////使用//RichTextBoxCtrl.richTextBoxFontClass r = new RichTextBoxCtrl.richTextBoxFontClass();//r.richTextBox = richTextBox1;//r.ToggleBold();namespace RichTextBoxCtrl{    class richTextBoxFontClass    {               public richTextBoxFontClass()        {            richTextBox = new RichTextBox();        }        public RichTextBox richTextBox;        //粗体        public void ToggleBold()        {            if (richTextBox.SelectionFont == null)                richTextBox.SelectionFont = richTextBox.Font;            FontStyle style = richTextBox.SelectionFont.Style;            if (richTextBox.SelectionFont.Bold)                style &= ~FontStyle.Bold;//恢复正常            else                style |= FontStyle.Bold;            richTextBox.SelectionFont = new Font(richTextBox.SelectionFont, style);        }        //斜体        public void ToggleItalic()        {            if (richTextBox.SelectionFont == null)                richTextBox.SelectionFont = richTextBox.Font;            FontStyle style = richTextBox.SelectionFont.Style;            if (richTextBox.SelectionFont.Italic)                style &= ~FontStyle.Italic;//恢复正常            else                style |= FontStyle.Italic;            richTextBox.SelectionFont = new Font(richTextBox.SelectionFont, style);        }        //下划线        public void ToggleUnderLine()        {            if (richTextBox.SelectionFont == null)                richTextBox.SelectionFont = richTextBox.Font;            FontStyle style = richTextBox.SelectionFont.Style;            if (richTextBox.SelectionFont.Underline)                style &= ~FontStyle.Underline;//恢复正常            else                style |= FontStyle.Underline;            richTextBox.SelectionFont = new Font(richTextBox.SelectionFont, style);        }        //删除线        public void ToggleStrikeout()        {            if (richTextBox.SelectionFont == null)                richTextBox.SelectionFont = richTextBox.Font;            FontStyle style = richTextBox.SelectionFont.Style;            if (richTextBox.SelectionFont.Strikeout)                style &= ~FontStyle.Strikeout;//恢复正常            else                style |= FontStyle.Strikeout;            richTextBox.SelectionFont = new Font(richTextBox.SelectionFont, style);        }    }}

 

转载于:https://www.cnblogs.com/xe2011/p/3446119.html

你可能感兴趣的文章
【10.20校内测试】【小模拟】【无向图建树判奇偶环】【树上差分】
查看>>
Quartz任务调度
查看>>
用python发送email
查看>>
Linux文件系统
查看>>
C# 与java区别总结 收集
查看>>
linux 安装jdk
查看>>
mongo文档操作
查看>>
HTTP协议
查看>>
【循序渐进学Python】6.Python中的函数
查看>>
django ORM中的RelatedManager(关联管理器)
查看>>
VA Code编写html(1)
查看>>
C# winForm 定时访问PHP页面小工具
查看>>
编写TreeSet类的实现程序,其中相关的迭代器使用二叉查找树
查看>>
Java作业08 计科1501 闫国雨
查看>>
IntelliJ IDEA+Mysql connecter/j JDBC驱动连接
查看>>
(转)SQL Case when 的使用方法
查看>>
oc基础-self关键字的使用
查看>>
Ext JS 5 beta版发布
查看>>
牛客网第4场A
查看>>
Laravel笔记记录
查看>>