使用

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);
}
}
}

richTextBoxFontClass的更多相关文章

随机推荐

  1. Java NIO之Selector

    选择器是JavaNIO重磅推出的一个概念:在旧有的系统中为了跟踪多端口消息,需要为每一个端口配备一个线程做监听:但是有了selector就不需要了,一个Selector可以管理一众渠道(channel ...

  2. 加密算法 - RSA算法一

    RSA算法原理(一)  声明: 本文转自 -- 作者: 阮一峰 (http://www.ruanyifeng.com/blog/2013/06/rsa_algorithm_part_one.html) ...

  3. 堆排序 海量数据求前N大的值

    最(大)小堆的性质: (1)是一颗完全二叉树,遵循完全二叉树的所有性质. (2)父节点的键值(大于)小于等于子节点的键值 堆的存储 一般都用数组来表示堆,i结点的父结点下标就为(i – 1) / 2. ...

  4. 第 3 章 单例模式【Singleton Pattern】

    以下内容出自:24种设计模式介绍与6大设计原则 这个模式是很有意思,而且比较简单,但是我还是要说因为它使用的是如此的广泛,如此的有人缘,单例就是单一.独苗的意思,那什么是独一份呢?你的思维是独一份,除 ...

  5. Java多线程初学者指南(10):使用Synchronized关键字同步类方法

    要想解决“脏数据”的问题,最简单的方法就是使用synchronized关键字来使run方法同步,代码如下: public synchronized void run() { ... } 从上面的代码可 ...

  6. JavaScript自学代码--(四)

    //JavaScript Window - 浏览器对象模型 window.document.getElementById("header"); //等价于 document.get ...

  7. CTSC && APIO 总结

    先说CTSC吧,第一试其实不难但是下意识觉得CTSC不就只能骗分吗,然后就全上暴力了.然而第二题再一次看漏了条件,即答案总和小于等于1e6.第三题现在回想起来要不然就是没有思考,要不然就是没学过数学, ...

  8. csu 10月 月赛 D 题 CX and girls

    Description CX是要赶去上课,为了不迟到必须要以最短的路径到达教室,同时CX希望经过的路上能看到的学妹越多越好.现在把地图抽象成一个无向图,CX从1点出发,教室在N号点,告诉每个点上学妹的 ...

  9. Python脚本调用C#代码数据交互示例(hello world)

    原地址: http://www.djangochina.cn/forum.php?mod=viewthread&tid=247 随着项目的逐渐收尾, 对IronPython脚本也越来越熟悉,这 ...

  10. maven 搭建企业级web项目

    就看这篇文章了:http://www.cnblogs.com/quanyongan/archive/2013/05/28/3103243.html