serch.cs

来自「记事本」· CS 代码 · 共 52 行

CS
52
字号
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 Serch : Form
    {
        private int pos = 0;
        public Serch()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (this.textBox1.Text != "")
            {
                Form1 f = (Form1)this.Owner;
                if (f.richTextBox1.Text.Length >0)
                {
                    if ((pos = f.richTextBox1.Text.IndexOf(textBox1.Text, pos)) == -1)
                    {
                        MessageBox.Show("没有找到");
                        pos = 0;
                    }
                    else
                    {
                        f.richTextBox1.Select(pos ,textBox1 .Text .Length );
                        pos = pos + textBox1.Text.Length;
                        f.Activate();
                    }
                }
            }

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            pos = 0;
        }
    }
}

⌨️ 快捷键说明

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