richTextBoxFontClass
使用
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的更多相关文章
随机推荐
- 跨域Ajax请求WebService方法
一.允许跨域Ajax请求,更改如下配置: 在要调用的WebService上面添加特性标签: 二.以如下返回用户信息的WebService方法为例 三.在另一个网站上通过Ajax访问webService ...
- 12个你未必知道的CSS小知识
虽然CSS并不是一种很复杂的技术,但就算你是一个使用CSS多年的高手,仍然会有很多CSS用法/属性/属性值你从来没使用过,甚至从来没听说过. 1.CSS的color属性并非只能用于文本显示 对于CSS ...
- requirejs学习博客址分享
1. http://blog.jobbole.com/30046/ 2. http://www.requirejs.cn/ 3. http://www.ruanyifeng.com/blog/2012 ...
- hdu 4714
一个树形dp的题,又是一个涉及不深的领域 = =: 不过在网上看到了大神用很巧的思路解决了这个题: 大神的思路就是: 从树的底部往上看:如果一棵子树拥有两个及以上的叶子节点,可以将这棵子树与大树分离 ...
- 算法练习之:Biorhythms
Biorhythms Time Limit: 1000MS Memory Limit: 10000KB Problem Description Some people believe that th ...
- java WebService简单使用案例
首先,建立一个WebService: package garfield; import javax.jws.WebService; import javax.xml.ws.Endpoint; @Web ...
- Android应用架构
Android开发生态圈的节奏非常之快.每周都会有新的工具诞生,类库的更新,博客的发表以及技术探讨.如果你外出度假一个月,当你回来的时候可能已经发布了新版本的Support Library或者Play ...
- asp.net中bin目录下的 dll.refresh文件
首先找到了这篇文章http://www.cnblogs.com/haokaibo/archive/2010/07/31/1789342.html 然后找到一篇英文的文章http://monsur.xa ...
- WCF 托管在IIS中遇到Http的错误
IIS8中部署WCF服务出错:HTTP 错误 404.3 - Not Found http://www.cnblogs.com/xwgli/archive/2013/03/15/2961022.htm ...
- redhat 6.5 使用其它Linux镜像源的yum源
最近在虚拟机里装了rhel_6.5_x86_64,发现竟然不自带g++,没办法只好 “yum install gcc-c++”,无奈失败,原因是redhat的yum是收费的... 于是打算怒装其它免费 ...