using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 设置字体和颜色
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void 字体FToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (richTextBox1.SelectionFont == null) return;
            else this.fontDialog1.Font = this.richTextBox1.SelectionFont;
            DialogResult result = this.fontDialog1.ShowDialog();
            if (result == DialogResult.OK)
                this.richTextBox1.SelectionFont = this.fontDialog1.Font;
        }

        private void 颜色CToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.colorDialog1.Color = this.richTextBox1.SelectionColor;
            DialogResult result = this.colorDialog1.ShowDialog();
            if (result == DialogResult.OK)
                this.richTextBox1.SelectionColor = this.colorDialog1.Color;
        }
    }
}

Logo

智能硬件社区聚焦AI智能硬件技术生态,汇聚嵌入式AI、物联网硬件开发者,打造交流分享平台,同步全国赛事资讯、开展 OPC 核心人才招募,助力技术落地与开发者成长。

更多推荐