使用

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. 如何利用C生成.so供Mono调用

    Mono诞生的初衷是为了吸引更多的Windows .Net程序员来加入Linux平台的开发.但在Linux世界中C语言依然是 主流.很多时候一些关键应用(比如大型 笛卡儿 乘积运算.需要调用平台硬件功 ...

  2. IOS webview中cookie的读取与保存-b

    Cookie 的读取 将它放在 webViewDidFinishLoad 开始后执行 NSArray *nCookies = [[NSHTTPCookieStorage sharedHTTPCooki ...

  3. 模拟键盘输入 : SendMessage, keybd_event, PostKeybdMessage

    转自模拟键盘输入 : SendMessage, keybd_event, PostKeybdMessage 目的 最近项目要求在Windows CE下模拟键盘输入,上网搜索了一下,发现有3个API可以 ...

  4. IAR编译ZStack-CC2530为可下载运行的HEX文件的正确配置

    转自IAR编译ZStack-CC2530为可下载运行的HEX文件的正确配置 IAR编译ZStack-CC2530为可下载运行的HEX文件的正确配置:        1.正确配置输出文件格式:菜单选择P ...

  5. 【NOIP2015 DAY1 T3 】斗地主(landlords)

    题目描述 牛牛最近迷上了一种叫斗地主的扑克游戏.斗地主是一种使用黑桃.红心.梅花.方片的A到K加上大小王的共54张牌来进行的扑克牌游戏.在斗地主中,牌的大小关系根据牌的数码表示如下:3<4< ...

  6. 李洪强漫谈iOS开发[C语言-034]-程序的结构

  7. UNIX网络编程——套接字选项

    http://www.educity.cn/linux/1241288.html 有时候我们需要控制套接字的行为(如修改缓冲区的大小),这个时候我们就要学习套接字选项. int getsockopt( ...

  8. cssViewer牛逼的chrome插件

    很牛逼,功能很强大.

  9. Apache Struts 安全措施绕过漏洞(CVE-2013-4310)

    漏洞版本: Apache Group Struts < 2.3.15.2 漏洞描述: BUGTRAQ ID: 62584 CVE(CAN) ID: CVE-2013-4310 Struts2 是 ...

  10. CentOS下date命令 - 显示和设置系统日期与时间

    显示系统日期 要显示系统日期,只要输入: $ date Thu Dec 5 22:55:41 WIB 2013 格式化显示日期 日期有很多格式.如果你不喜欢默认的格式,你可以换一种格式.你可能会想&q ...