⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form5.cs

📁 简易文本编辑器 便于书写 适合初学者参考 也可进一步改进
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
    public partial class Form5 : Form
    {
        public Form5()
        {
            InitializeComponent();
        }
        public RichTextBox s1;
        public int start,rep2;
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {

                string str1, str2;
                str1 = textBox1.Text;
                str2 = textBox2.Text;
                if ((str1 == "") || (str2 == ""))
                {
                    MessageBox.Show("请确认替换内容!", "异常警示");
                }
                else
                {
                    start = s1.Find(str1, start, RichTextBoxFinds.MatchCase);
                    if (start != -1)
                    {
                        {
                            s1.SelectedText = str2;
                            start = start + str2.Length;
                            start = s1.Find(str1, start, RichTextBoxFinds.MatchCase);
                        }
                        start = 0;
                        s1.Focus();
                    }
                    else
                    {
                        MessageBox.Show("替换结束!", "结束替换");
                    }
                }
            }
            catch
            {
                MessageBox.Show("当前文档替换已经结束!", "警示");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            string str1, str2;
            str1 = textBox1.Text;
            str2 = textBox2.Text;
            start = 0;
            start = s1.Find(str1, start, RichTextBoxFinds.MatchCase);
            while (start != -1)
            {
                rep2 = rep2 + 1;
               s1.SelectedText = str2;
                start = start + str2.Length;
                start = s1.Find(str1, start, RichTextBoxFinds.MatchCase);
            }
            MessageBox.Show("应警惕换到文档结尾!,全部替换结束");
            start = 0;
            s1.Focus();
        }

        private void Form5_Load(object sender, EventArgs e)
        {

        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -