zoukankan      html  css  js  c++  java
  • 设置字体格式

     private void btnBold_Click(object sender, EventArgs e)
            {
                Font oldfont, newfont;
                oldfont 
    = this.richTextBox1.SelectionFont;//获取选定字的字体格式
                if (oldfont.Bold)
                {
                    newfont 
    = new Font(oldfont, oldfont.Style &~FontStyle.Bold);//清除粗体字格式
                }
                
    else
                    newfont 
    = new Font(oldfont, oldfont.Style | FontStyle.Bold); //设置为粗体字格式
                richTextBox1.SelectionFont = newfont;
                richTextBox1.Focus();
            }

            
    private void btnUnderline_Click(object sender, EventArgs e)
            {
                Font oldfont, newfont;
                oldfont 
    = this.richTextBox1.SelectionFont;//获取选定字的字体格式
                if (oldfont.Underline)
                {
                    newfont 
    = new Font(oldfont, oldfont.Style & ~FontStyle.Underline);//清除下划线字格式
                }
                
    else
                    newfont 
    = new Font(oldfont, oldfont.Style | FontStyle.Underline); //设置为下划线字格式
                richTextBox1.SelectionFont = newfont;
                richTextBox1.Focus();
            }

            
    private void btnItalic_Click(object sender, EventArgs e)
            {
                Font oldfont, newfont;
                oldfont 
    = this.richTextBox1.SelectionFont;//获取选定字的字体格式
                if (oldfont.Italic)
                {
                    newfont 
    = new Font(oldfont, oldfont.Style & ~FontStyle.Italic);//清除斜体字格式
                }
                
    else
                    newfont 
    = new Font(oldfont, oldfont.Style | FontStyle.Italic); //设置为斜体字字格式
                richTextBox1.SelectionFont = newfont;
                richTextBox1.Focus();
            }

            
    private void btnCenter_Click(object sender, EventArgs e)
            {
                
    if (richTextBox1.SelectionAlignment == HorizontalAlignment.Left)
                    richTextBox1.SelectionAlignment 
    = HorizontalAlignment.Center;
                
    else
                    richTextBox1.SelectionAlignment 
    = HorizontalAlignment.Left;
                richTextBox1.Focus();
            }

    未完,待续................
  • 相关阅读:
    libev & libevent简介
    MyEclipse10+Flash Builder4+BlazeDS+Tomcat7配置J2EE Web项目报错(一)
    增加表空间大小的四种方法
    JavaScript获取某年某月的最后一天
    Not in 改写左连接不需要关注连接列是否重复数据
    自连接
    左链接,右连接
    In,内链接和空值
    HighCharts基本折线图
    NetBeans运行项目报错
  • 原文地址:https://www.cnblogs.com/perfect/p/576437.html
Copyright © 2011-2022 走看看