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

    未完,待续................
  • 相关阅读:
    Ubuntu开发环境配置
    win7和Ubuntu16.04之间相互远程控制
    QT学习之usb摄像头采集(Opencv+QT)[cvCapture,IplImage,QImage]
    Opencv 图像畸变矫正(after 相机标定, 获得内参和畸变参数)
    opencv角点检测、棋盘格检测、亚像素cvFindCornerSubPix()
    开始学习机加工钣金加工
    今夜的硬件之旅
    关于做实验
    机器学习部分题目
    ubuntu18.10配置git和github
  • 原文地址:https://www.cnblogs.com/perfect/p/576437.html
Copyright © 2011-2022 走看看