使用

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. WF工作流与管理类应用系统工作流需求实现的一些误区

             如今实现各种应用系统大家都知道工作流是一个非常重要的环节,不同的业务系统的工作流需求是需要找相应的工作流产品去实现的,因为不同工作流产品的架构细节也许会成为某类需求实现的瓶颈. WF ...

  2. Uva10766 Organising the Organisation

    题目链接戳这里 基尔霍夫矩阵裸题.构建基尔霍夫矩阵(度数矩阵-邻接矩阵),求他的任意\(n-1\)阶主子式的绝对值即为答案. 这题开始用java写,结果BigInteger太慢Tle了. 后来用c++ ...

  3. Qt, QT/E, Qtopia 的区别

    转自Qt, QT/E, Qtopia 的区别 Qt泛指Qt的所有桌面版本,比如Qt/X11,Qt Windows,Qt Mac等.由于Qt最早是在Linux中随着KDE流行开来的,因此通常很多人说的Q ...

  4. eclipse提交本地项目到github

    1.在https://github.com   new repository 2.在eclipse中new project  比如:Test项目 3.右击"Test"->Te ...

  5. C++控制台程序中使用定时器

    转自博客:http://www.cnblogs.com/phinecos/archive/2008/03/08/1096691.html 作者:洞庭散人 “我现在项目是一个控制台程序,用到的Win32 ...

  6. POJ_2739_Sum_of_Consecutive_Prime_Numbers_(尺取法+素数表)

    描述 http://poj.org/problem?id=2739 多次询问,对于一个给定的n,求有多少组连续的素数,满足连续素数之和为n. Sum of Consecutive Prime Numb ...

  7. cocos2d-x 添加自定义字体---中文,英文

    1: 找到字体   xxx.ttf 2: 在xcode工程的 Info.plist文件中添加key Fonts provided by application,   或者 UIAppFonts(raw ...

  8. java JdbcTemplate源码

    package com.wl.filter; package org.javaresearch.jerch; import java.lang.reflect.Method; import java. ...

  9. 排序 O(nlogn)

    1. 堆排序是一种优秀的排序算法,时间复杂度O(nlogn),主要思想是用数组构造一个最大堆,满足跟节点的value>子节点的value,然后将堆顶元素(value最大)与最后一个叶子节点交换, ...

  10. poj 2586 Y2K Accounting Bug

    http://poj.org/problem?id=2586 大意是一个公司在12个月中,或固定盈余s,或固定亏损d. 但记不得哪些月盈余,哪些月亏损,只能记得连续5个月的代数和总是亏损(<0为 ...